Gradle可以自动化地进行软件构建、测试、发布、部署、软件打包,同时也可以完成项目相关功能如:生成静态网站、生成文档等
- 环境配置
略 - 创建gradleWEB项目
勾选web选项,自动创建src目录
填写groupid和artifacId(创建成功为项目名称)
选择修改gradle配置自动导入
使用本地gradle 并指定gradle目录
选择finish创建成功
再次打开,选择gradle配置文件
并配置编码,防止java文件乱码
添加web.xml文件及WEB-INF文件夹(web项目使用)
添加war包插件
打war包
添加tomcat中并运行
ok!
- gradle配置SSM使用
//引入ssm包
testCompile group: 'junit', name: 'junit', version: '4.12'
compile 'org.apache.tomcat:tomcat-servlet-api:8.0.24'
compile 'jstl:jstl:1.2'
compile 'org.springframework:spring-beans:4.1.7.RELEASE'//springbeans框架
compile 'org.springframework:spring-web:4.1.7.RELEASE'//spring框架
compile 'org.springframework:spring-webmvc:4.1.7.RELEASE'//springmvc框架
compile 'org.springframework:spring-tx:4.1.7.RELEASE'//spring事务
compile 'org.springframework:spring-jdbc:4.1.7.RELEASE'//spring 对JDBC 数据访问进行封装的所有类
compile 'com.alibaba:druid:1.0.15'//数据库连接池
compile 'org.aspectj:aspectjweaver:1.8.6'//springaop依赖包
compile 'mysql:mysql-connector-java:5.1.36'
compile 'org.mybatis:mybatis-spring:1.2.3'
compile 'org.mybatis:mybatis:3.3.0'
compile 'junit:junit:4.12'
compile 'org.springframework:spring-test:4.0.5.RELEASE'//单元测试使用 事务等。
providedCompile 'javax.servlet:servlet-api:2.5'//servlet支持使用