//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.0http:
//maven.apache.org/maven-v4_0_0.xsd">
4.0.0
StateGrid
web
war
1.0-SNAPSHOT
webMavenWebapp
http:
//maven.apache.org
4.0.3.RELEASE
5.1.38
--测试-->
junit
junit
4.12
test
com.github.pagehelper
pagehelper
4.1.4
--spring-->
org.springframework
spring-webmvc
${spring.version}
org.springframework
spring-test
${spring.version}
org.springframework.security
spring-security-web
${spring.version}
org.springframework
spring-core
${spring.version}
org.springframework
spring-jdbc
${spring.version}
--引入servlet-->
javax.servlet
javax.servlet-api
3.1.0
--json包-->
org.codehaus.jackson
jackson-mapper-asl
1.9.13
com.fasterxml.jackson.core
jackson-databind
2.8.5
--fastjson包-->
---->
--com.alibaba-->
--fastjson-->
--1.1.39-->
---->
--支持文件上传的包-->
commons-fileupload
commons-fileupload
1.3.1
--整合mybatis使用-->
org.mybatis
mybatis
3.3.0
org.mybatis
mybatis-spring
1.2.0
--mysql数据库-->
mysql
mysql-connector-java
${mysql.connector.version}
--数据源-->
com.alibaba.druid
druid-wrapper
0.2.9
--切面-->
org.aspectj
aspectjweaver
1.7.1
--引入servlet-->
javax.servlet
javax.servlet-api
3.1.0
web
3,在IDEA中建立新WEB工程
1、
2、
3、
4、
5、
6、
7、
8、
9、
10、用同样方法建立Test文件夹,注意位置在src下,与main平行位置。
11、用同样的方法建立yangzhou(工程名称)文件夹在java下,并将已经自动生成的model和dao文件夹拷贝至yangzhou文件夹下。
12、将5个配置文件
和已经自动生成的mapping文件夹拷贝至resources文件夹下。
其中,config.properties文件夹内容如下:
13、##JDBCGlobalSetting
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:
mysql:
//127.0.0.1/yangzhou?
useUnicode=true&characterEncoding=utf-8
jdbc.username=root
jdbc.password=1234567890
#jdbc.backupPath=/var/
##mysql的跟目录
#mysql.lumu=/var
##mysql的bin目录
#mysql.binPath=/var/
##DataSourceGlobalSetting
#配置初始化大小、最小、最大
ds.initialSize=3
ds.minIdle=1
ds.maxActive=20
#获取连接的最大等待时间
ds.maxWaitTime=60000
validationQuery=SELECT1
#redis配置
redis.host=127.0.0.1
redis.port=6379
redis.pass=
redis.maxIdle=300
redis.maxActive=600
redis.maxWait=1000
redis.testOnBorrow=true
Log4j.properties的内容如下:
#DEBUG或者INFO
log4j.rootLogger=DEBUG,Console,File
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.Target=System.out
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=[%c]%m%n
log4j.appender.File=org.apache.log4j.RollingFileAppender
log4j.appender.File.File=logs/log.log
log4j.appender.File.Append=true
log4j.appender.File.MaxFileSize=10MB
log4j.appender.File.Threshold=ALL
log4j.appender.File.layout=org.apache.log4j.PatternLayout
log4j.appender.File.layout.ConversionPattern=[%p][%d{yyyy-MM-ddHH\:
mm\:
ss,SSS}][%c]%m%n
Spring.xml内容如下:
xmlversion="1.0"encoding="UTF-8"?
>
//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.1.xsd
http:
//www.springframework.org/schema/context
http:
//www.springframework.org/schema/context/spring-context-3.1.xsd">
--引入属性文件-->
property-placeholderlocation="classpath:
config.properties"/>
--自动扫描(自动注入)-->
component-scanbase-package="yangzhou.service"/>
spring-mybatis.xml"/>
Spring-mvc的配置如下:
xmlversion="1.0"encoding="UTF-8"?
>
//www.springframework.org/schema/beans"
xmlns:
xsi="http:
//www.w3.org/2001/XMLSchema-instance"
xmlns:
p="http:
//www.springframework.org/schema/p"
xmlns:
context="http:
//www.springframework.org/schema/context"
xmlns:
mvc="http:
//www.springframework.org/schema/mvc"xmlns:
util="http:
//www.springframework.org/schema/util"
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
http:
//www.springframework.org/schema/mvc
http:
//www.springframework.org/schema/mvc/spring-mvc.xsdhttp:
//www.springframework.org/schema/utilhttp:
//www.springframework.org/schema/util/spring-util.xsd">
--@Controller必须指定annotation-->
annotation-driven/>
--自动扫描controller包下的所有类,使其认为springmvc的控制器-->
component-scanbase-package="yangzhou.controller"/>
--避免IE执行AJAX时,返回JSON出现下载文件-->
text/html;charset=UTF-8
--启动SpringMVC的注解功能,完成请求和注解POJO的映射-->
--json转换器-->
--对模型视图名称的解析,即在模型视图名称添加前后缀-->
prefix="/html/"p:
suffix=".html"/>
UTF-8
32505856
--上传文件大小限制为31M,31*1024*1024-->
4096
Spring-mybatis的配置如下:
xmlversion="1.0"encoding="UTF-8"?
>
//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.1.xsd
http:
//www.springframework.org/schema/context
http:
//www.springframework.org/schema/context/spring-context-3.1.xsd">
--引入属性文件-->
property-placeholderlocation="classpath:
config.properties"/>
--dataSource配置-->
--初始化连接大小-->
--连接池最大使用连接数量-->
--连接池最小空闲-->
--获取连接最大等待时间-->
--配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒-->
--配置一个连接在池中最小生存的时间,单位是毫秒-->
--打开removeAbandoned功能-->
--1800秒,也就是30分钟-->
--关闭abanded连接时输出错误日志-->
--监控数据库-->