欢迎点击「算法与编程之美」↑关注我们!
本文首发于微信公众号:"算法与编程之美",欢迎关注,及时了解更多此系列文章。
作者|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 团队
微信号:算法与编程之美
温馨提示:点击页面右下角“写留言”发表评论,期待您的参与!期待您的转发!