1、打开idea,直接new一个project。
选中maven一直next,需要输入的地方输入自己喜欢的名字即可!


2、新建好项目后直接删除src文件夹,新建两个目录service和web,并且分别放一个pom.xml文件。


3、修改3个pom.xml的内容,代码如下:
项目的pom.xml包含web和service两个模块:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.river</groupId>
<artifactId>good_ssm</artifactId>
<packaging>pom</packaging>
<version>1.0</version>
<modules>
<module>web</module>
<module>service</module>
</modules>
</project>
service的pom打成jar包:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>service</artifactId>
<parent>
<artifactId>good_ssm</artifactId>
<groupId>com.river</groupId>
<version>1.0</version>
</parent>
<packaging>jar</packaging>
</project>
web的pom.xml打成war包,并包含service.jar:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>web</artifactId>
<parent>
<groupId>com.river</groupId>
<artifactId>good_ssm</artifactId>
<version>1.0</version>
</parent>
<packaging>war</packaging>
<dependencies>
<!--打包的时候包含service.jar-->
<dependency>
<groupId>com.river</groupId>
<artifactId>service</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</project>
4、新建目录 src | main | java | resources | webapp | WEB-INF

5、定义目录属性(java文件夹定义为Sources Root,resources文件夹定义为Resources Root)

6、加入web.xml并配置tomcat
web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<display-name>good_ssm 1.0</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>





再new一个index.jsp就可以运行和访问浏览器了!
7、加入spring、springmvc和mybatis的依赖(我整理好了,缺一不可,有相应的说明!)
8、web.xml中配置spring监听器和springmvc
9、加入spring配置文件并在web.xml中配置路径
10、新建Controller层、Service层和Dao层以及mybatis的持久层映射文件
11、数据库密码加密显示,框架搭建完成!
最终形成的目录如下:

下面开始粘贴代码,也可以下载我已经搭建好的项目!地址:https://download.youkuaiyun.com/download/river66/11065819。觉得有用的兄弟可以点个赞吗^_^
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<display-name>good_ssm 1.0</display-name>
<!-- spring配置文件 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/application-*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- 配置Spring MVC过滤器 -->
<servlet>
<servlet-name>spring-mvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/mvc-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring-mvc</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
application-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
">
<!-- 配置注解扫描 -->
<context:annotation-config />
<!-- 自动扫描的包名 -->
<context:component-scan base-package="com.good.frame" />
<!-- 加载配置文件 -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="ignoreUnresolvablePlaceholders" value="true"/>
<property name="locations">
<list>
<value>classpath:config.properties</value>
</list>
</property>
</bean>
</beans>
application-mvc.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd ">
<!--根据@RequestMapping注解进行映射解析-->
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping">
<property name="order" value="1"/>
</bean>
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<property name="webBindingInitializer" ref="webBindingInitializer"/>
<property name="messageConverters">
<list>
<!-- Json消息转换-->
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html;charset=UTF-8</value>
<value>application/json;charset=UTF-8</value>
</list>
</property>
<property name="objectMapper">
<bean class="com.good.frame.util.FormatObjectMapper"/>
</property>
</bean>
</list>
</property>
</bean>
<bean id="webBindingInitializer" class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">
<property name="conversionService" ref="conversionService"/>
<!--<property name="validator" ref="validator"/>-->
</bean>
<bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
<property name="converters">
<set>
</set>
</property>
</bean>
<!-- Multipart文件上传解析 -->
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="defaultEncoding" value="UTF-8"/>
<property name="maxUploadSize" value="2000000"/>
</bean>
</beans>
application-mybatis.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"
default-lazy-init="true" default-autowire="byName">
<!-- 数据源 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
<property name="driverClass" value="${${database.type}.jdbc.driverClassName}"/>
<property name="jdbcUrl" value="${${database.type}.jdbc.url}"/>
<property name="properties" ref="dataSourceProperties"/>
<!--<property name="autoCommitOnClose" value="false"/>-->
<property name="checkoutTimeout" value="${cpool.checkoutTimeout}"/>
<property name="initialPoolSize" value="${cpool.minPoolSize}"/>
<property name="minPoolSize" value="${cpool.minPoolSize}"/>
<property name="maxPoolSize" value="${cpool.maxPoolSize}"/>
<property name="maxIdleTime" value="${cpool.maxIdleTime}"/>
<property name="acquireIncrement" value="${cpool.acquireIncrement}"/>
<property name="maxIdleTimeExcessConnections" value="${cpool.maxIdleTimeExcessConnections}"/>
<property name="idleConnectionTestPeriod" value="${cpool.idleConnectionTestPeriod}"/>
<property name="testConnectionOnCheckout" value="true"/>
</bean>
<bean id="dataSourceProperties" class="com.good.frame.factory.PropertiesEncryptFactoryBean">
<property name="properties">
<props>
<prop key="user">${jdbc.username}</prop>
<prop key="password">${jdbc.password}</prop>
</props>
</property>
</bean>
<!--基于注解的事务管理-->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"/>
<property name="globalRollbackOnParticipationFailure" value="false" /> <!--指定此参数为false-->
</bean>
<tx:annotation-driven transaction-manager="transactionManager"/>
<bean id="lazySqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="configLocation" value="classpath:mybatis/mybatis-config.xml"/>
<!-- 当mybatis的xml文件和mapper接口不在相同包下时,需要用mapperLocations属性指定xml文件的路径。
*是个通配符,代表所有的文件,**代表所有目录下 -->
<property name="mapperLocations" value="classpath:mapper/**/*.xml" />
</bean>
<!-- 扫描mybatis映射接口类 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.good.frame.dao"/>
<property name="sqlSessionFactoryBeanName" value="lazySqlSessionFactory"/>
</bean>
</beans>
mvc-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
</beans>
config.properties
#DB type
database.type=mysql
mysql.jdbc.driverClassName=com.mysql.jdbc.Driver
mysql.jdbc.url=jdbc:mysql://localhost:3306/ssm?useUnicode=true&characterEncoding=utf8
jdbc.username=3B73289CE2F67296
jdbc.password=3B73289CE2F67296
#POOL CONFIG
cpool.checkoutTimeout=60000
cpool.minPoolSize=2
cpool.maxPoolSize=200
cpool.maxIdleTime=60
cpool.maxIdleTimeExcessConnections=60
cpool.acquireIncrement=2
cpool.idleConnectionTestPeriod=5000
mybatis-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<typeAliases>
<typeAlias alias="user" type="com.good.frame.bean.User"/>
</typeAliases>
</configuration>
User.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!-- 用户相关信息处理 -->
<mapper namespace="com.good.frame.dao.IUserDao">
<resultMap type="user" id="userMap">
<id property="id" column="id"/>
<result property="userName" column="user_name"/>
<result property="password" column="password"/>
</resultMap>
<insert id="insertUser" parameterType="user">
insert into user (user_name,password)
values (#{userName},#{password})
</insert>
</mapper>
下面是java代码:
User.java
public class User {
private String userName;
private String password;
//省略了getter/setter/constructor
}
UserController.java
@Controller
@RequestMapping(value = "/user", method = {RequestMethod.POST, RequestMethod.GET})
public class UserController {
@Autowired
UserService userService;
@ResponseBody
@RequestMapping("/addUser.do")
public String addUser(String userName, String password) {
if(userName == null && password == null)
return "参数错误!";
User user = new User(userName, userName);
boolean isSuccess = userService.addUser(user);
if (isSuccess)
return "添加用户成功!";
else
return "添加失败!";
}
}
IUserService.java
public interface IUserService {
boolean addUser(User user);
}
UserService.java
@Service
public class UserService implements IUserService {
@Autowired
IUserDao userDao;
@Override
public boolean addUser(User user) {
int flag = userDao.insertUser(user);
if(flag == 0)
return false;
else
return true;
}
}
IUserDao.java
public interface IUserDao {
int insertUser(User user);
}
PropertiesEncryptFactoryBean.java
public class PropertiesEncryptFactoryBean implements FactoryBean {
private Properties properties;
private static String KEY = "river";
public Object getObject() throws Exception {
return getProperties();
}
public Class getObjectType() {
return Properties.class;
}
public boolean isSingleton() {
return true;
}
public Properties getProperties() {
return properties;
}
public void setProperties(Properties inProperties) {
this.properties = inProperties;
properties.put("user", decrypt(properties.getProperty("user")));
properties.put("password", decrypt(properties.getProperty("password")));
}
/** 解密 */
private static String decrypt(String encryptedData) {
return DESUtil.getInstance().decode(encryptedData, KEY);
}
}
DESUtil.java
public class DESUtil {
public static final String DES = "DES";
public static final String charset = "UTF-8";
public static final int keysizeDES = 0;
private static DESUtil instance;
private DESUtil() {
}
// 单例
public static DESUtil getInstance() {
if (instance == null) {
synchronized (DESUtil.class){
if (instance == null) {
instance = new DESUtil();
}
}
}
return instance;
}
/**
* 使用 DES 进行加密
*/
public String encode(String res, String key) {
return keyGeneratorES(res, DES, key, keysizeDES, true);
}
/**
* 使用 DES 进行解密
*/
public String decode(String res, String key) {
return keyGeneratorES(res, DES, key, keysizeDES, false);
}
// 使用KeyGenerator双向加密,DES/AES,注意这里转化为字符串的时候是将2进制转为16进制格式的字符串,不是直接转,因为会出错
private String keyGeneratorES(String res, String algorithm, String key, int keysize, boolean isEncode) {
try {
KeyGenerator kg = KeyGenerator.getInstance(algorithm);
if (keysize == 0) {
byte[] keyBytes = charset == null ? key.getBytes() : key.getBytes(charset);
kg.init(new SecureRandom(keyBytes));
} else if (key == null) {
kg.init(keysize);
} else {
byte[] keyBytes = charset == null ? key.getBytes() : key.getBytes(charset);
kg.init(keysize, new SecureRandom(keyBytes));
}
SecretKey sk = kg.generateKey();
SecretKeySpec sks = new SecretKeySpec(sk.getEncoded(), algorithm);
Cipher cipher = Cipher.getInstance(algorithm);
if (isEncode) {
cipher.init(Cipher.ENCRYPT_MODE, sks);
byte[] resBytes = charset == null ? res.getBytes() : res.getBytes(charset);
return parseByte2HexStr(cipher.doFinal(resBytes));
} else {
cipher.init(Cipher.DECRYPT_MODE, sks);
return new String(cipher.doFinal(parseHexStr2Byte(res)));
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
// 将二进制转换成16进制
private String parseByte2HexStr(byte buf[]) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < buf.length; i++) {
String hex = Integer.toHexString(buf[i] & 0xFF);
if (hex.length() == 1) {
hex = '0' + hex;
}
sb.append(hex.toUpperCase());
}
return sb.toString();
}
// 将16进制转换为二进制
private byte[] parseHexStr2Byte(String hexStr) {
if (hexStr.length() < 1)
return null;
byte[] result = new byte[hexStr.length() / 2];
for (int i = 0; i < hexStr.length() / 2; i++) {
int high = Integer.parseInt(hexStr.substring(i * 2, i * 2 + 1), 16);
int low = Integer.parseInt(hexStr.substring(i * 2 + 1, i * 2 + 2), 16);
result[i] = (byte) (high * 16 + low);
}
return result;
}
}
FormatObjectMapper.java
public class FormatObjectMapper extends ObjectMapper {
public FormatObjectMapper()
{
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
this.setDateFormat(sdf);
}
}
最后是3个pom.xml文件:
good_ssm——pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.river</groupId>
<artifactId>good_ssm</artifactId>
<packaging>pom</packaging>
<version>1.0</version>
<modules>
<module>web</module>
<module>service</module>
</modules>
<properties>
<spring.version>4.3.14.RELEASE</spring.version>
<aspectj.version>1.6.11</aspectj.version>
<jackson.version>2.7.4</jackson.version>
</properties>
<dependencyManagement>
<dependencies>
<!--spring的依赖包主要是以下7个-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency>
<!--RequestMappingHandlerAdapter会依赖到以下三个-->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<!-- multipartResolver需要用到以下三个 -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<!--spring+mybatis-->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.6</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.5.2</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
web——pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>web</artifactId>
<parent>
<groupId>com.river</groupId>
<artifactId>good_ssm</artifactId>
<version>1.0</version>
</parent>
<packaging>war</packaging>
<dependencies>
<!--打包的时候包含service.jar-->
<dependency>
<groupId>com.river</groupId>
<artifactId>service</artifactId>
<version>1.0</version>
</dependency>
<!--@ResponseBody、@RequestMapping和@Controller等都用到这个依赖-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<!--RequestMappingHandlerMapping依赖这个-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
<!-- multipartResolver需要依赖这个 -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
</dependency>
<!--mybatis-->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</dependency>
<dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
</dependencies>
</project>
service——pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>service</artifactId>
<parent>
<artifactId>good_ssm</artifactId>
<groupId>com.river</groupId>
<version>1.0</version>
</parent>
<packaging>jar</packaging>
<dependencies>
<!--@ResponseBody、@RequestMapping和@Controller等都用到这个依赖-->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
</dependency>
<!--RequestMappingHandlerAdapter会依赖到这个-->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<!--spring+mybatis-->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<!--Compiler插件编译时和编译后运行的JVM版本目前默认的设置为1.5,使用这个插件指定JVM编译版本-->
<!--如果没有加这个会提示:Warning:java: 源值1.5已过时, 将在未来所有发行版中删除-->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
maven依赖的仓库:https://mvnrepository.com/search?q=spring,可以自行下载需要的版本!
有什么疑问的都可以评论留言,我都会看的!如果有什么问题会误导大家的,还请大神们指出来,我好更正过来!
如果对您有用的话赞一下呗!谢谢啦!
本文详细介绍了一个基于Spring、Spring MVC及MyBatis(SSM)框架的项目搭建过程,包括项目结构设计、配置文件编写及核心代码实现。
3万+

被折叠的 条评论
为什么被折叠?



