how to create separate war for my front end (angul

2019-06-05 21:28发布

问题:

I am using this directory structure :

Parent
 | 
 |--Back-end(one module FOR enitity)
 |   |- pom.xml
 |
 |--Back-end(one module FOR rest)
 |   |- pom.xml
 |
 |--Back-end(one module FOR service)
 |   |- pom.xml
 |
 |--Front-end(module for angular)
 |   |-public
 |   |    |-myApp
 |   |        |-all angularjs related files
 |   
 |
 |
 |pom.xml  

My back-end module produces a WAR but now how to make separate war for angular : the goal here is to be able to deploy the entire javascript application(angularjs) as a java war file.

回答1:

Try to use <packaging>jar</packaging> for all modules. Then create two new modules which have <packaging>war</packaging> and which depend on the plain JARs created by the other modules.

That way, you can reuse the Java code in your WARs. If you want to share files below WEB-INF, then you can create a common WAR module for that and use WAR overlays. This means you have many modules which produce JARs and three that produce WARs. Note that WAR overlays are somewhat brittle, so it's often better to stay away from them.