【Maven项目如何转换为Gradle项目】

#Idea中Maven工程如何转换为Gradle工程

  1. 打开Maven项目

  2. 修改settings中Maven的本地仓库
    在这里插入图片描述

  3. 修改settings中项目的编码格式
    在这里插入图片描述

4.刷新Maven的相应插件
在这里插入图片描述

5.在Idea中TerMinal输入“gradle init --type pom”,根据提示设置参数
在这里插入图片描述
根据提示输入"1"选择Groovy
在这里插入图片描述
格局提示输入"no" 选择默认
在这里插入图片描述

5、刷新项目–项目已转换成功
在这里插入图片描述

6、点击右下角提示,此时会报错,修改settings配置Gradle本地仓库等
在这里插入图片描述

7、修改settings配置Gradle本地仓库等
在这里插入图片描述

7、配置项目中的build.gradle文件

/*
 * This file was generated by the Gradle 'init' task.
 */

plugins {
    /**删除掉
        id 'java'
        id 'maven-publish'
     **/
    id 'war' //添加id 'war'
}

repositories {
    mavenLocal()
    maven {
        url = uri('https://repo.maven.apache.org/maven2/')
    }
}

dependencies {
    implementation 'org.springframework:spring-context:5.3.1'
    implementation 'org.springframework:spring-beans:5.3.1'
    implementation 'org.springframework:spring-web:5.3.1'
    implementation 'org.springframework:spring-webmvc:5.3.1'
    implementation 'org.springframework:spring-jdbc:5.3.1'
    implementation 'org.springframework:spring-aspects:5.3.1'
    implementation 'org.springframework:spring-test:5.3.1'
    implementation 'org.mybatis:mybatis:3.5.7'
    implementation 'org.mybatis:mybatis-spring:2.0.6'
    implementation 'com.alibaba:druid:1.0.9'
    implementation 'mysql:mysql-connector-java:8.0.16'
    implementation 'log4j:log4j:1.2.17'
    implementation 'com.github.pagehelper:pagehelper:5.2.0'
    implementation 'ch.qos.logback:logback-classic:1.2.3'
    implementation 'com.fasterxml.jackson.core:jackson-databind:2.12.1'
    implementation 'commons-fileupload:commons-fileupload:1.3.1'
    implementation 'org.thymeleaf:thymeleaf-spring5:3.0.12.RELEASE'
    testImplementation 'junit:junit:4.12'
    providedCompile 'javax.servlet:javax.servlet-api:3.1.0'
}

/** 删除掉
     * group = 'com.lizheng'
     version = '1.0-SNAPSHOT'
     description = 'myweb01'
     java.sourceCompatibility = JavaVersion.VERSION_1_8

     publishing {
     publications {
     maven(MavenPublication) {
        from(components.java)
     }
     }
     }
 */

8、刷新插件进行下载
在这里插入图片描述

9、发布到tomcat中
在这里插入图片描述

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值