前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Maven项目转Gradle项目

Maven项目转Gradle项目

作者头像
算法与编程之美
发布2019-07-17 17:52:32
1.4K0
发布2019-07-17 17:52:32
举报
文章被收录于专栏:算法与编程之美

欢迎点击「算法与编程之美」↑关注我们!

本文首发于微信公众号:"算法与编程之美",欢迎关注,及时了解更多此系列文章。

作者|olive丶

来源|

https://blog.csdn.net/asd1098626303/article/details/79141315

由于习惯采用gradle来构建项目,网上很多开源项目都是使用maven来构建项目,查阅资料发现pom.xml转化成build.gradle只需要一条命令:

通过在项目目录,使用gradle init --type pom这条命令来构建。

构建完后新增build.grale 和 seetting.gradle文件

原文件:

POM.XML

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <name>商城</name> <description>基于Spring框架实现</description> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.1.RELEASE</version> </parent> <groupId>com.vito16</groupId> <artifactId>shop</artifactId> <version>1.1</version> <packaging>war</packaging> <properties> <mysql.version>5.1.38</mysql.version> <druid.version>1.0.17</druid.version> <tomcat.version>7.0.59</tomcat.version> <guava.version>19.0</guava.version> </properties> <dependencies> <!--WEB--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!--<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-velocity</artifactId> </dependency>--> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> </dependency> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-jasper</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-logging</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> <dependency> <groupId>com.google.guava</groupId> <artifactId>guava</artifactId> <version>${guava.version}</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql.version}</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>${druid.version}</version> </dependency> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.1</version> </dependency> <dependency> <groupId>commons-fileupload</groupId> <artifactId>commons-fileupload</artifactId> <version>1.3.1</version> </dependency> <dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>2.4</version> </dependency> <dependency> <groupId>joda-time</groupId> <artifactId>joda-time</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <fork>true</fork> <addResources>true</addResources> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <useSystemClassLoader>false</useSystemClassLoader> </configuration> </plugin> <plugin> <groupId>org.eluder.coveralls</groupId> <artifactId>coveralls-maven-plugin</artifactId> <version>4.3.0</version> </plugin> </plugins> </build>

转化后的build.gradle:

apply plugin: 'java' apply plugin: 'idea' apply plugin: 'maven' group = 'com.vito16' version = '1.1' description = """""" sourceCompatibility = 1.5 targetCompatibility = 1.5 repositories { maven { url "http://repo.maven.apache.org/maven2" } } dependencies { compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version:'1.5.1.RELEASE' compile group: 'javax.servlet', name: 'jstl', version:'1.2' compile group: 'org.apache.tomcat.embed', name: 'tomcat-embed-jasper', version:'7.0.59' compile group: 'org.springframework.boot', name: 'spring-boot-starter-logging', version:'1.5.1.RELEASE' compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version:'1.5.1.RELEASE' compile group: 'com.google.guava', name: 'guava', version:'19.0' compile group: 'mysql', name: 'mysql-connector-java', version:'5.1.38' compile group: 'com.alibaba', name: 'druid', version:'1.0.17' compile group: 'org.apache.commons', name: 'commons-lang3', version:'3.1' compile group: 'commons-fileupload', name: 'commons-fileupload', version:'1.3.1' compile group: 'commons-io', name: 'commons-io', version:'2.4' compile group: 'joda-time', name: 'joda-time', version:'2.9.7' testCompile(group: 'org.springframework.boot', name: 'spring-boot-starter-test', version:'1.5.1.RELEASE') { exclude(module: 'commons-logging') } } //gradle init --type pom

END

主 编 | 张祯悦

责 编 | olive

where2go 团队


微信号:算法与编程之美

温馨提示:点击页面右下角“写留言”发表评论,期待您的参与!期待您的转发!

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2019-05-18,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 算法与编程之美 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云数据库 SQL Server
腾讯云数据库 SQL Server (TencentDB for SQL Server)是业界最常用的商用数据库之一,对基于 Windows 架构的应用程序具有完美的支持。TencentDB for SQL Server 拥有微软正版授权,可持续为用户提供最新的功能,避免未授权使用软件的风险。具有即开即用、稳定可靠、安全运行、弹性扩缩等特点。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档