码迷,mamicode.com
首页 > 其他好文 > 详细

最新SSM框架整合2019

时间:2019-09-01 18:57:19      阅读:251      评论:0      收藏:0      [点我收藏+]

标签:pos   versions   通过   time   ima   ini   gif   compiler   ota   

我比较笨,这个框架整合给我搞得疲惫,还是思路不清晰,走着走着我就一片茫然

配置:

技术图片

声明:

所有maven引入资源都从https://mvnrepository.com/这里取得。

STEP1:

创建maven web项目:

技术图片

STEP2:

创建好后,文件夹,package补全:

技术图片

STEP3:

 使用servlet3,并修改web.xml头部信息

技术图片
1   <!--使用servlet3-->
2         <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
3         <dependency>
4             <groupId>javax.servlet</groupId>
5             <artifactId>javax.servlet-api</artifactId>
6             <version>3.1.0</version>
7             <scope>provided</scope>
8         </dependency>
View Code
技术图片
1 <?xml version="1.0" encoding="UTF-8"?>
2 <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee  http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
4          version="3.0">
5     <welcome-file-list>
6         <welcome-file>index.jsp</welcome-file>
7     </welcome-file-list>
8 </web-app>
View Code

 STEP4:

引入最新的spring版本;(5.1.9.RELEASE)

spring-context,spring-core,spring-beans,spring-web,spring-webmvc,spring-test,

STEP5:

创建几个spring配置文件,并配置其中一个

技术图片

 

 技术图片

 

 添加一个测试:

技术图片

 

 将配置文件加入web.xml

技术图片
 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 3          xsi:schemaLocation="http://java.sun.com/xml/ns/javaee  http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
 4          version="3.0">
 5     <welcome-file-list>
 6         <welcome-file>index.jsp</welcome-file>
 7     </welcome-file-list>
 8     <servlet>
 9         <servlet-name>dispatcherServletSpring</servlet-name>
10         <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
11         <init-param>
12             <param-name>contextConfigLocation</param-name>
13             <param-value>classpath:spring/spring-*.xml</param-value>
14         </init-param>
15     </servlet>
16     <servlet-mapping>
17         <servlet-name>dispatcherServletSpring</servlet-name>
18         <url-pattern>/</url-pattern>
19     </servlet-mapping>
20 </web-app>
web.xml

结果:

技术图片

 

 STEP6:

maven引入mysql-connector-java,spring-jdbc.

技术图片

 

 书写jdbc.properties

技术图片
1 jdbc.user=root
2 jdbc.password=123456
3 jdbc.driver=com.mysql.cj.jdbc.Driver
4 jdbc.url=jdbc:mysql:///xyz?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT
jdbc.properties

引入c3p0,使用人数最多的,0.9.5.2,,,spring-tx,,

引入mybatis,mybatis-spring

 


 

已经验证可以用了,有点多,不想写了,这是链接:

1 链接:https://pan.baidu.com/s/1uv5ioiyLybu3tYlp5cEHKw 
2 提取码:lt5u 
3 复制这段内容后打开百度网盘手机App,操作更方便哦

一般入门问题都在这些包环境上,这是pom.xml,这一套可以通过测试;

  1 <?xml version="1.0" encoding="UTF-8"?>
  2 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  4     <modelVersion>4.0.0</modelVersion>
  5 
  6     <groupId>sadness.xyz</groupId>
  7     <artifactId>website01</artifactId>
  8     <version>1.0-SNAPSHOT</version>
  9     <packaging>war</packaging>
 10 
 11     <name>website01 Maven Webapp</name>
 12     <!-- FIXME change it to the project‘s website -->
 13     <url>http://www.example.com</url>
 14 
 15     <properties>
 16         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
 17         <maven.compiler.source>1.8</maven.compiler.source>
 18         <maven.compiler.target>1.8</maven.compiler.target>
 19     </properties>
 20 
 21     <dependencies>
 22 
 23         <!-- https://mvnrepository.com/artifact/log4j/log4j -->
 24         <dependency>
 25             <groupId>log4j</groupId>
 26             <artifactId>log4j</artifactId>
 27             <version>1.2.17</version>
 28         </dependency>
 29         <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 -->
 30         <dependency>
 31             <groupId>org.slf4j</groupId>
 32             <artifactId>slf4j-log4j12</artifactId>
 33             <version>1.7.25</version>
 34             <scope>test</scope>
 35         </dependency>
 36         <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
 37         <dependency>
 38             <groupId>org.slf4j</groupId>
 39             <artifactId>slf4j-api</artifactId>
 40             <version>1.7.25</version>
 41         </dependency>
 42         <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
 43         <dependency>
 44             <groupId>org.slf4j</groupId>
 45             <artifactId>slf4j-simple</artifactId>
 46             <version>1.7.25</version>
 47             <scope>test</scope>
 48         </dependency>
 49 
 50 
 51         <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
 52         <dependency>
 53             <groupId>com.fasterxml.jackson.core</groupId>
 54             <artifactId>jackson-databind</artifactId>
 55             <version>2.10.0.pr1</version>
 56         </dependency>
 57         <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
 58         <dependency>
 59             <groupId>com.fasterxml.jackson.core</groupId>
 60             <artifactId>jackson-core</artifactId>
 61             <version>2.10.0.pr1</version>
 62         </dependency>
 63         <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations -->
 64         <dependency>
 65             <groupId>com.fasterxml.jackson.core</groupId>
 66             <artifactId>jackson-annotations</artifactId>
 67             <version>2.10.0.pr1</version>
 68         </dependency>
 69 
 70 
 71         <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
 72         <dependency>
 73             <groupId>org.mybatis</groupId>
 74             <artifactId>mybatis</artifactId>
 75             <version>3.5.2</version>
 76         </dependency>
 77         <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis-spring -->
 78         <dependency>
 79             <groupId>org.mybatis</groupId>
 80             <artifactId>mybatis-spring</artifactId>
 81             <version>2.0.2</version>
 82         </dependency>
 83 
 84         <!-- https://mvnrepository.com/artifact/com.mchange/c3p0 -->
 85         <dependency>
 86             <groupId>com.mchange</groupId>
 87             <artifactId>c3p0</artifactId>
 88             <version>0.9.5.2</version>
 89         </dependency>
 90         <!-- https://mvnrepository.com/artifact/org.springframework/spring-tx -->
 91         <dependency>
 92             <groupId>org.springframework</groupId>
 93             <artifactId>spring-tx</artifactId>
 94             <version>5.1.9.RELEASE</version>
 95         </dependency>
 96 
 97         <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
 98         <dependency>
 99             <groupId>mysql</groupId>
100             <artifactId>mysql-connector-java</artifactId>
101             <version>8.0.17</version>
102         </dependency>
103 
104 
105         <!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
106         <dependency>
107             <groupId>org.springframework</groupId>
108             <artifactId>spring-context</artifactId>
109             <version>5.1.9.RELEASE</version>
110         </dependency>
111         <!-- https://mvnrepository.com/artifact/org.springframework/spring-core -->
112         <dependency>
113             <groupId>org.springframework</groupId>
114             <artifactId>spring-core</artifactId>
115             <version>5.1.9.RELEASE</version>
116         </dependency>
117         <!-- https://mvnrepository.com/artifact/org.springframework/spring-beans -->
118         <dependency>
119             <groupId>org.springframework</groupId>
120             <artifactId>spring-beans</artifactId>
121             <version>5.1.9.RELEASE</version>
122         </dependency>
123         <!-- https://mvnrepository.com/artifact/org.springframework/spring-web -->
124         <dependency>
125             <groupId>org.springframework</groupId>
126             <artifactId>spring-web</artifactId>
127             <version>5.1.9.RELEASE</version>
128         </dependency>
129         <!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
130         <dependency>
131             <groupId>org.springframework</groupId>
132             <artifactId>spring-webmvc</artifactId>
133             <version>5.1.9.RELEASE</version>
134         </dependency>
135         <!-- https://mvnrepository.com/artifact/org.springframework/spring-test -->
136         <dependency>
137             <groupId>org.springframework</groupId>
138             <artifactId>spring-test</artifactId>
139             <version>5.1.9.RELEASE</version>
140             <scope>test</scope>
141         </dependency>
142         <!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc -->
143         <dependency>
144             <groupId>org.springframework</groupId>
145             <artifactId>spring-jdbc</artifactId>
146             <version>5.1.9.RELEASE</version>
147         </dependency>
148 
149 
150         <!--使用servlet3-->
151         <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
152         <dependency>
153             <groupId>javax.servlet</groupId>
154             <artifactId>javax.servlet-api</artifactId>
155             <version>3.1.0</version>
156             <scope>provided</scope>
157         </dependency>
158 
159         <dependency>
160             <groupId>junit</groupId>
161             <artifactId>junit</artifactId>
162             <version>4.12</version>
163             <scope>test</scope>
164         </dependency>
165     </dependencies>
166 
167     <build>
168         <finalName>website01</finalName>
169         <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
170             <plugins>
171                 <plugin>
172                     <artifactId>maven-clean-plugin</artifactId>
173                     <version>3.1.0</version>
174                 </plugin>
175                 <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
176                 <plugin>
177                     <artifactId>maven-resources-plugin</artifactId>
178                     <version>3.0.2</version>
179                 </plugin>
180                 <plugin>
181                     <artifactId>maven-compiler-plugin</artifactId>
182                     <version>3.8.0</version>
183                 </plugin>
184                 <plugin>
185                     <artifactId>maven-surefire-plugin</artifactId>
186                     <version>2.22.1</version>
187                 </plugin>
188                 <plugin>
189                     <artifactId>maven-war-plugin</artifactId>
190                     <version>3.2.2</version>
191                 </plugin>
192                 <plugin>
193                     <artifactId>maven-install-plugin</artifactId>
194                     <version>2.5.2</version>
195                 </plugin>
196                 <plugin>
197                     <artifactId>maven-deploy-plugin</artifactId>
198                     <version>2.8.2</version>
199                 </plugin>
200             </plugins>
201         </pluginManagement>
202     </build>
203 </project>

 

最新SSM框架整合2019

标签:pos   versions   通过   time   ima   ini   gif   compiler   ota   

原文地址:https://www.cnblogs.com/red-flag-dance/p/11441930.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!