Use Gradle in Eclipse to build a Java Web project, eclipsegradle

Source: Internet
Author: User
Tags jcenter

Use Gradle in Eclipse to build a Java Web project, eclipsegradle

Gradle is an automated construction tool that uses DSL to declare Project Settings. With Gradle, you can configure project dependencies and automatically download the dependent files, greatly improving the efficiency of project building.

1. Install Gradle

Download the latest version of Gradle, decompress it, set the environment variable GRADLE_HOME, and add % GRADLE_HOME % \ bin to the Path;

2. Install the Gradle plug-in

Search for Gradle in Eclipse Help-> Eclipse Marketplace and install Buildship;

3. Create a Gradle Project

Choose File> New> Other> Gradle Project to create a Gradle Project:

Set the Gradle path and Java path:

4. convert a Project to a Web Project

Right-click the Project, choose Properties> Project Facets, and select Dynamic Web Module:

5. Configure Gradle

Open the build. gradle file and edit it as follows:

/** This build file was auto generated by running the Gradle 'init 'Task * by 'simon 'at '16-11-17 Juan 2:49' with Gradle 3.2 ** This generated file contains a sample Java project to get you started. * For more details take a look at the Java Quickstart chapter in the Gradle * user guide available at https://docs.gradle.org/3.2/userguide/tutorial_java_projects.html * // Apply the java plugin to add support for Javaapply plugin: 'java' // In this section you declare where to find the dependencies of your projectrepositories {// Use 'jcenter' for resolving your dependencies. // You can declare any Maven/Ivy/file repository here. jcenter ()} // In this section you declare the dependencies for your production and test codedependencies {// struts library compile group: 'org. apache. struts ', name: 'struts 2-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-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 '// common library compile 'org. slf4j: slf4j-api: 1.7.13 'testCompile' junit: 4.12 '}

The repository uses jcenter () or mavenCentral (), but jcenter () is better, including mavenCentral (). The Struts, Spring, and Hibernate files and some other commonly used files are configured in the dependency.

Click the Run button of Gradle Executions to automatically download the dependent files of the above configuration. Is it more convenient than before? Of course, if you already have these files, you can also rely on local files.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.