利用 Intellij IDEA +MAVEN+Jetty实现SpringMVC读取数据库数据并显示在页面上的简单功能

1 新建maven项目,配置pom.xml

  1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  2          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  3   <modelVersion>4.0.0</modelVersion>
  4   <groupId>SpringJDBCTest1</groupId>
  5   <artifactId>SpringJDBCTest1</artifactId>
  6   <packaging>war</packaging>
  7   <version>1.0-SNAPSHOT</version>
  8   <name>SpringJDBCTest1 Maven Webapp</name>
  9   <url>http://maven.apache.org</url>
 10 
 11   <dependencies>
 12 
 13     <!--spring-->
 14     <dependency>
 15       <groupId>org.springframework</groupId>
 16       <artifactId>spring-beans</artifactId>
 17       <version>4.3.1.RELEASE</version>
 18     </dependency>
 19 
 20     <dependency>
 21       <groupId>org.springframework</groupId>
 22       <artifactId>spring-core</artifactId>
 23       <version>4.3.1.RELEASE</version>
 24     </dependency>
 25 
 26     <dependency>
 27       <groupId>org.springframework</groupId>
 28       <artifactId>spring-context</artifactId>
 29       <version>4.3.1.RELEASE</version>
 30     </dependency>
 31 
 32     <!--Spring Web + Spring MVC-->
 33     <dependency>
 34       <groupId>org.springframework</groupId>
 35       <artifactId>spring-web</artifactId>
 36       <version>4.3.1.RELEASE</version>
 37     </dependency>
 38     <dependency>
 39       <groupId>org.springframework</groupId>
 40       <artifactId>spring-webmvc</artifactId>
 41       <version>4.3.1.RELEASE</version>
 42     </dependency>
 43 
 44     <!--NoClassDefFoundError: javax/servlet/jsp/jstl/core/Config-->
 45     <!-- https://mvnrepository.com/artifact/javax.servlet/jstl -->
 46     <dependency>
 47       <groupId>javax.servlet</groupId>
 48       <artifactId>jstl</artifactId>
 49       <version>1.2</version>
 50     </dependency>
 51 
 52     <dependency>
 53       <groupId>taglibs</groupId>
 54       <artifactId>standard</artifactId>
 55       <version>1.1.2</version>
 56     </dependency>
 57 
 58     <!--servlet/jsp api start-->
 59     <dependency>
 60       <groupId>javax.servlet</groupId>
 61       <artifactId>servlet-api</artifactId>
 62       <version>2.5</version>
 63     </dependency>
 64 
 65     <!-- https://mvnrepository.com/artifact/javax.servlet.jsp/jsp-api -->
 66     <dependency>
 67       <groupId>javax.servlet.jsp</groupId>
 68       <artifactId>jsp-api</artifactId>
 69       <version>2.2</version>
 70     </dependency>
 71 
 72     <!--mysql driver-->
 73     <dependency>
 74       <groupId>mysql</groupId>
 75       <artifactId>mysql-connector-java</artifactId>
 76       <version>5.1.6</version>
 77     </dependency>
 78 
 79     <!--jdbc-->
 80     <dependency>
 81       <groupId>org.springframework</groupId>
 82       <artifactId>spring-jdbc</artifactId>
 83       <version>3.0.5.RELEASE</version>
 84     </dependency>
 85 
 86     <!--c3p0-->
 87     <dependency>
 88       <groupId>com.mchange</groupId>
 89       <artifactId>c3p0</artifactId>
 90       <version>0.9.5.1</version>
 91     </dependency>
 92 
 93     <!--aspectj-->
 94     <dependency>
 95       <groupId>org.aspectj</groupId>
 96       <artifactId>aspectjweaver</artifactId>
 97       <version>1.8.6</version>
 98     </dependency>
 99 
100     <dependency>
101       <groupId>org.aspectj</groupId>
102       <artifactId>aspectjrt</artifactId>
103       <version>1.8.6</version>
104     </dependency>
105 
106     <!--mybatis-->
107     <dependency>
108       <groupId>org.mybatis</groupId>
109       <artifactId>mybatis</artifactId>
110       <version>3.3.0</version>
111     </dependency>
112 
113     <!--mybatis spring整合-->
114     <dependency>
115       <groupId>org.mybatis</groupId>
116       <artifactId>mybatis-spring</artifactId>
117       <version>1.2.3</version>
118     </dependency>
119 
120   </dependencies>
121 
122   <build>
123     <finalName>SpringJDBCTest1</finalName>
124 
125     <plugins>
126       <!--servlet容器 jetty插件-->
127       <plugin>
128         <groupId>org.eclipse.jetty</groupId>
129         <artifactId>jetty-maven-plugin</artifactId>
130         <version>9.3.10.v20160621</version>
131       </plugin>
132 
133       <!--mybatis 逆向工程插件-->
134       <plugin>
135         <groupId>org.mybatis.generator</groupId>
136         <artifactId>mybatis-generator-maven-plugin</artifactId>
137         <version>1.3.2</version>
138         <configuration>
139           <verbose>true</verbose>
140           <overwrite>true</overwrite>
141         </configuration>
142       </plugin>
143       <plugin>
144         <groupId>org.apache.maven.plugins</groupId>
145         <artifactId>maven-compiler-plugin</artifactId>
146         <configuration>
147           <source>1.7</source>
148           <target>1.7</target>
149         </configuration>
150       </plugin>
151     </plugins>
152   </build>
153 </project>
View Code

相关文章: