Spring
Mybatis
Springmvc
4.0.0
com.bjpowernode
mimissm
1.0
war
4.12
5.2.5.RELEASE
3.5.1
1.3.1
1.2.15
8.0.22
1.1.12
5.1.2
3.0.1
2.0
1.2
1.6.4
2.9.6
org.springframework
spring-context
${spring.version}
org.springframework
spring-beans
${spring.version}
org.springframework
spring-webmvc
${spring.version}
org.springframework
spring-jdbc
${spring.version}
org.springframework
spring-aspects
${spring.version}
org.springframework
spring-jms
${spring.version}
org.springframework
spring-context-support
${spring.version}
org.springframework
spring-test
${spring.version}
org.mybatis
mybatis
${mybatis.version}
org.mybatis
mybatis-spring
${mybatis.spring.version}
com.github.miemiedev
mybatis-paginator
${mybatis.paginator.version}
com.github.pagehelper
pagehelper
${pagehelper.version}
mysql
mysql-connector-java
${mysql.version}
com.alibaba
druid
${druid.version}
junit
junit
${junit.version}
test
jstl
jstl
${jstl.version}
javax.servlet
javax.servlet-api
3.0.1
provided
javax.servlet
jsp-api
provided
${jsp-api.version}
com.fasterxml.jackson.core
jackson-databind
${jackson.version}
org.json
json
20140107
commons-io
commons-io
2.4
commons-fileupload
commons-fileupload
1.3.1
org.mybatis.generator
mybatis-generator-maven-plugin
1.3.7
org.mybatis.generator
mybatis-generator-core
1.3.7
mysql
mysql-connector-java
${mysql.version}
org.apache.maven.plugins
maven-compiler-plugin
3.8.1
1.8
UTF-8
src/main/java
**/*.properties
**/*.xml
false
src/main/resources
**/*.properties
**/*.xml
false
jdbc.url=jdbc:mysql://localhost:3306/xiaomissm?user=root&password=&useUnicode=true&characterEncoding=gbk&serverTimezone=Asia/Shanghai
jdbc.driverClass=com.mysql.cj.jdbc.Driver
jdbc.user=xxxx
jdbc.passward=xxxxxx
Archetype Created Web Application
contextConfigLocation
classpath*:applicationContext.xml
org.springframework.web.context.AbstractContextLoaderInitializer
springmvc
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath*:springmvc.xml
springmvc
*.do
什么是工具配置类呢,在上文我们成功搭建了SSM的基本框架并成功的运行出来的helloworld程序;
当然,这样的程序是十分简单的,但他的配置却十分繁琐,这也是本篇文章的目的,提供基本工具配置模板而达到简单复用并快速实现搭建SSM的意义。
逆向生成dao/mapper/entity
generatorConfiguration
逆向工程插件
<!-- 具体插件,逆向工程的操作是以构建过程中插件形式出现的 -->
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.7</version>
<!-- 插件的依赖 -->
<dependencies>
<!-- 逆向工程的核心依赖 -->
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.7</version>
</dependency>
<!-- MySQL驱动 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>
</dependencies>
</plugin>
逆向工程配置文件
DOCTYPE generatorConfiguration
PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
<properties resource="db.Properties"/>
<context id="default" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressData" value="false"/>
<property name="suppressAllComments" value="false"/>
commentGenerator>
<jdbcConnection driverClass="${jdbc.driverClass}"
connectionURL="${jdbc.url}"
userId="${jdbc.user}"
password="${jdbc.passward}">
<property name="nullCatalogMeansCurrent" value="true"/>
<property name="useSSL" value="false"/>
jdbcConnection>
<javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
javaTypeResolver>
<javaModelGenerator targetPackage="entity" targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
javaModelGenerator>
<sqlMapGenerator targetPackage="mapper" targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
sqlMapGenerator>
<javaClientGenerator type="XMLMAPPER" targetPackage="dao" targetProject="src/main/java">
<property name="enableSubPackages" value="true"/>
javaClientGenerator>
<table tableName="tb_order" domainObjectName="tbOrder" enableCountByExample="false"
enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
table>
<table tableName="tb_order" domainObjectName="tbOrder" enableCountByExample="false"
enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
table>
context>
generatorConfiguration>
3、 实际效果:
按照预期生成了dao\mapper\entity
###
# Set root category priority to INFO and its only appender to CONSOLE.
#log4j.rootCategory=INFO, CONSOLE debug info warn error fatal
log4j.rootCategory=debug, CONSOLE, LOGFILE
# Set the enterprise logger category to FATAL and its only appender to CONSOLE.
log4j.logger.org.apache.axis.enterprise=FATAL, CONSOLE
# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{ISO8601} %-6r [%15.15t] %-5p %30.30c %x - %m\n
# LOGFILE is set to be a File appender using a PatternLayout.
log4j.appender.LOGFILE=org.apache.log4j.FileAppender
log4j.appender.LOGFILE.File=d:D:\\IDEA\\WorkingPlace\\learn\\mybatisOut.log
log4j.appender.LOGFILE.Append=true
log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.LOGFILE.layout.ConversionPattern=%d{ISO8601} %-6r [%15.15t] %-5p %30.30c %x - %m\n