Gradle 搭建 SSM (Spring + SpringMVC + Mybatis)

前置内容:

   A、=> Gradle安装配置

   B、=> Eclipse 安装 Gradle插件


项目整体结构:




步骤:

1、新建一个Dynamic Web Project   , 项目名ssm3

2、对ssm3添加Gradle支持 , 右击项目—>Configure—>Add Gradle Nature

3、在Java Resources 下添加 resources 目录 用于存放配置文件

4、在项目根目录下新建build.gradle,添加包依赖

5、下载依赖包,右击项目—>Gradle—>Refresh Gradle Project,等待依赖包下载完成(每次refresh之后需要执行小步骤)

     5.1 把 src 和 resources 添加到build path

     5.2 Default output folder 设置成 ssm3/WebContent/WEB-INF/classes       (ssm3是项目名称

     5.3  把src 、 resources 、 WebContent目录添加到 Deployment and Assembly

6、整合Spring-Mybatis

     6.1 配置mybatis

     6.2  开发pojo,mapper ,service

     6.3  测试 mybatis

7、整合Spring MVC

8、配置web.xml















build.gradle  内容:

apply plugin: 'java'
apply plugin: 'war' //用来生成war
apply plugin: 'eclipse-wtp' //用来生成Eclipseweb项目的插件(web-tool-platform)
version = '1.0' //property
 
// Uses JDK 7
sourceCompatibility = 1.7
targetCompatibility = 1.7
 
// 1. Get dependencies from Maven local repository
// 2. Get dependencies from Maven central repository
repositories {
//mavenCentral()
maven{ url"http://maven.aliyun.com/nexus/content/groups/public"}  
}
 
//Project dependencies
dependencies {
 compile 'org.apache.tomcat:tomcat-servlet-api:8.0.24'
 compile 'jstl:jstl:1.2'
 compile 'org.springframework:spring-beans:4.3.5.RELEASE'
 compile 'org.springframework:spring-context:4.3.5.RELEASE'
 compile 'org.springframework:spring-context-support:4.3.5.RELEASE'
 compile 'org.springframework:spring-web:4.3.5.RELEASE'
 compile 'org.springframework:spring-webmvc:4.3.5.RELEASE'
 compile 'org.springframework:spring-tx:4.3.5.RELEASE'
 compile 'com.alibaba:druid:1.0.15'
 compile 'org.aspectj:aspectjweaver:1.8.6'
 compile 'mysql:mysql-connector-java:5.1.36'
 compile 'org.mybatis:mybatis-spring:1.3.1'
 compile 'org.mybatis:mybatis:3.4.1'
 compile 'org.springframework:spring-jdbc:4.3.5.RELEASE'
 compile 'junit:junit:4.12'
 compile 'org.springframework:spring-test:4.0.5.RELEASE'
 compile 'com.alibaba:fastjson:1.2.31'
 compile 'log4j:log4j:1.2.17'
 compile group: 'org.freemarker', name: 'freemarker', version: '2.3.25-incubating'
 compile group: 'commons-fileupload', name: 'commons-fileupload', version: '1.3.1'
 compile group: 'commons-io', name: 'commons-io', version: '2.2'
 compile group: 'commons-logging', name: 'commons-logging', version: '1.2'
 
 //compile group: 'org.codehaus.jackson', name: 'jackson-mapper-asl', version: '1.9.13'
 //compile group: 'org.codehaus.jackson', name: 'jackson-core-asl', version: '1.9.13'
 


//include in compile only, exclude in the war
providedCompile 'javax.servlet:servlet-api:3.0.1'
providedCompile 'javax.servlet.jsp:jsp-api:2.2.1-b03'
}







第4、 第5步之后的Project Explorer项目视图




5.1  

5.2






5.3







使用上图步骤依次添加src 、 resources 、 WebContent目录到 Deployment and Assembly






5.3 步骤设置完成后,第4、 第5步之后的Project Explorer项目视图





整合Spring-Mybatis




jdbc.properties


driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/base1
username=btuser
password=t123
#\u5B9A\u4E49\u521D\u59CB\u8FDE\u63A5\u6570
initialSize=0
#\u5B9A\u4E49\u6700\u5927\u8FDE\u63A5\u6570
maxActive=20
#\u5B9A\u4E49\u6700\u5927\u7A7A\u95F2
maxIdle=20
#\u5B9A\u4E49\u6700\u5C0F\u7A7A\u95F2
minIdle=1
#\u5B9A\u
  • 3
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值