gradle项目发布到自定义的tomcate中

今天第一次利用gradle构建工具。如果你想问 Maven和Gradle的区别 ,请自行去百度吧,因为我也说不上来,哈哈哈~~~~~~反正maven现在正在落后,而gradle正在崛起!

1、首先在eclipse中安装Gradle的插件

      help>Eclipse Marketplace   搜索Gradle即可   我安装的是黑色小象的那个  名字叫做‘Buildship Gradle Integration 2.0’

2、创建Gradle工程

File》new》other》gradle文件夹》Gradle project  点击next 出现如下界面

继续点击next:


取个工程名,第一次建点击next  要进行一些配置


这是你安装的gradle的地址,然后点击next  会自动找jdk


点击finish就可以啦  目录结构如下:


在build.gradle中可以对其进行配置,依赖包什么的  比maven会简单点

我的build.gradle的内容是:

/*
 * This build file was generated by the Gradle 'init' task.
 *
 * This generated file contains a sample Java Library project to get you started.
 * For more details take a look at the Java Libraries chapter in the Gradle
 * user guide available at https://docs.gradle.org/3.5.1/userguide/java_library_plugin.html
 */

// Apply the war plugin to add support for Java  
apply plugin: 'war'  
apply plugin: 'java'
apply plugin: 'eclipse-wtp'   

// In this section you declare where to find the dependencies of your project
repositories {
    // Use jcenter for resolving your dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()
}

dependencies {
 
	// struts library
    compile group: 'org.apache.struts', name: 'struts2-core', version: '2.3.24.1'
    compile 'org.apache.struts:struts2-spring-plugin:2.3.24.1'
    compile 'org.apache.struts:struts2-json-plugin:2.3.24.1'
 
    // spring library
    compile group: 'org.springframework', name: 'spring-core', version: '4.2.3.RELEASE'
    compile group: 'org.springframework', name: 'spring-web', version: '4.2.3.RELEASE'
    compile group: 'org.springframework', name: 'spring-orm', version: '4.2.3.RELEASE'
    compile group: 'org.springframework', name: 'spring-aop', version: '4.2.3.RELEASE'
    compile group: 'org.springframework', name: 'spring-beans', version: '4.2.4.RELEASE'
    compile group: 'org.springframework', name: 'spring-context', version: '4.2.4.RELEASE'
    compile group: 'org.springframework', name: 'spring-web', version: '4.2.4.RELEASE'
    compile group: 'org.springframework', name: 'spring-webmvc', version: '4.2.4.RELEASE'
    compile group: 'org.springframework', name: 'spring-aspects', version: '4.2.3.RELEASE'
    compile group: 'org.springframework', name: 'spring-jdbc', version: '4.2.3.RELEASE'
     
    // hibernate library  
    compile group: 'org.hibernate', name: 'hibernate-core', version: '5.0.1.Final'


    // This dependency is used internally, and not exposed to consumers on their own compile classpath.
    implementation 'com.google.guava:guava:21.0'

    // Use JUnit test framework
    testImplementation 'junit:junit:4.12'
}
等你加入依赖包以后  会自动下载,也可以自己弄  在项目上右击》gradle》refresh gradle project

3、下面就可以运行在tomcat上   重要的是 标注红色的代码 一定要用  不然是不能部署到tomcat中的。

然后就启动tomcat  在浏览器中输入地址 就可以啦


恭喜你!完成了gradle工程部署到tomcat上了。



如果有写的不对的地方 ,请留言指正!共同进步!


摘自:http://m.blog.csdn.net/hwsdau/article/details/75087242

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值