2018-07-15 (IDEA)Maven to build

2018-07-16  本文已影响0人  猪迹

Note

In the practice, we may want to divide the system into modules, some are just library to be referenced by other modules, to help co-work & maintenance of the system.
This guide resolves the question of 'copying the JAR from another local project' under the conditions:

And this project just use the pure Maven, not Spring-Boot.

Step 1 Create the parent project

We define the whole system as a project, which contains other project as its modules. So firstly we need to create the high-level project. This parent-project doesn't need to contain any code.

Step 2 Create the main-entry

Step 3 Run the main-entry from command-line

We can add some configuration to the pom.xml to tell it the main-entry-class

Step 4 Add a library

We suppose to use some library to hold shared interfaces/classes/utilities. It could be referenced by other parts of the project.

Step 5 Make provider to depend on service

From the command-line we know that even IDEA imported the class for us, Maven doesn't know it. To fix this, open pom.xml of provider, manually add the dependency to module service

mj0029.png

Step 6 Copy the referenced JAR to lib\

From the output of the step-5, we see that we can build the JAR, but failed when trying to run it.
The error says that it cannot find SampleClass.
By checking the content under provider\target, we found that there is not a JAR from the module service.
We already defined a lib/ in the pom.xml of module provider, in step-3, so we will try some way to copy the referenced JARs into the lib folder.

mj0032.png

More

These are left for future reading...

Reference

上一篇 下一篇

猜你喜欢

热点阅读