使用Gradle搭建SSM

该博客介绍了如何在Eclipse中安装Gradle插件,并通过Gradle搭建一个包含DAO层、Service层和Web资源的SSM项目。文章详细阐述了项目的目录结构,包括源代码、配置文件和视图资源的位置。同时提到了开发测试类,如UserController.java,并引用了一篇关于使用Maven构建SSM的参考文章。
摘要由CSDN通过智能技术生成

1、在eclipse中安装Gradle插件



2、新建Gradle Project
    方法一:直接新建


 方法二:
1)  直接新建一个Dynamic Web Project
2)  右击项目—>Configure—>Convert to Gradle Prorject


3、转换项目之后,在src下如下目录,其中java放置源代码,resources放置配置文件,webapp放置视图资源和web.xml。



3、 在项目根目录下新建build.gradle,下载依赖包
  1)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()
}
 
//Project dependencies
dependencies {
 compile 'org.apache.tomcat:tomcat-servlet-api:8.0.24'
 compile 'jstl:jstl:1.2'
 compile 'org.springframework:spring-beans:4.1.7.RELEASE'
 compile 'org.springframework:spring-web:4.1.7.RELEASE'
 compile 'org.springframework:spring-webmvc:4.1.7.RELEASE'
 compile 'org.springframework:spring-tx:4.1.7.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.2.3'
 compile 'org.mybatis:mybatis:3.3.0'
 compile 'org.springframework:spring-jdbc:4.1.7.RELEASE'
 compile 'junit:junit:4.12'
 compile 'org.springframework:spring-test:4.0.5.RELEASE'

//include in compile only, exclude in the war
providedCompile 'javax.servlet:servlet-api:2.5'
}

在build.gradle文件中配置我们项目需要依赖的包,这些我们使用的是maven仓库中的资源。关于这些jar包在哪里找的,这里推荐一个网站: http://www.mvnrepository.com/

  2)下载依赖包
  右击项目—>Gradle—>Refresh Dependencies,等待依赖下载完成。


4、整合Spring-Mybatis
  1)配置文件

spring-mybatis.xml配置文件
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值