intellij idea to create a polymerization engineering gradle

First create the parent project:

first step: 

next 

 

 

Take a good name, the parent project name: gradle-parent to create a common project with the same Click Finish to finish

 

Create sub-projects:

Step two:

 

next 

 

 Take a good name, sub-project name: demo-web to create a common project with the same Click Finish to finish

 

The third step: the demo-web project turned into a web project

A copy elsewhere webapp directory file, comprising WEB-INFO web-xml to the under src / main.

 

 

In build.gralde the demo-web file was added: apply plugin: 'war'

 

Refresh, refresh may not, on wepapp directory icon will be more of a blue dot, it is to identify the web project, as:

 

 

Step Four: Also create a sub-project: demo-service, non-web project, just a jar works, it does not require forced into a step above web project

 

the fifth step:

In build.gradle files under gradle-parent project which is written on dependencies {}

 

Step Six: This time, the child will inherit the parent project engineering jar package. In the sub-projects which require a separate jar package which can be in the sub-project

              Inside configuration.

Step Seven: Let the demo-web project references demo-service.

              In build.gralde file in the demo-web project directory writes: compile project ( ": demo-service")

 

Step eight: the before looking for a web project, take over, the inside of the controller classes in demo-web. service class in a demo-service.

The last tests run, or to publish a kind tomcat with the previous mavne project.

 

 

 

               

 

Guess you like

Origin www.cnblogs.com/jingzhi-sksk/p/12631771.html