I have 2 web projects in Spring MVC that are similar and have the same services and models. I want to split the code in order to have a common CORE.
I created a new project (CORE) with all the services and models that are shared and exported it as jar as specified here (Auto-wiring annotations in classes from dependent jars) but the components are not scanned and auto-wired in CHILD projects.
So, my questions are:
What are the other options besides jars to make the auto-wire happen?
What is the best practice to split code base and share the core components in spring projects?
Something like the below. See http://books.sonatype.com/mvnex-book/reference/multimodule.html for more info.
Maven parent module /pom.xml
:
...
<groupId>com.example</groupId>
<artifactId>parent</artifactId>
<version>X.X-TAG</version>
<packaging>pom</packaging>
<modules>
<module>core</module>
<module>child1</module>
</modules>
...
Maven core module: /core/pom.xml
:
...
<parent>
<artifactId>parent</artifactId>
<groupId>com.example</groupId>
<version>X.X-TAG</version>
</parent>
<packaging>jar</packaging>
<artifactId>core</artifactId>
...
Maven child1 module: /child1/pom.xml
:
...
<parent>
<groupId>com.example</groupId>
<artifactId>parent</artifactId>
<version>X.X-TAG</version>
</parent>
<packaging>war</packaging>
<artifactId>child1</artifactId>
<dependencies>
<dependency>
<groupId>${parent.groupId}</groupId>
<artifactId>core</artifactId>
<version>${parent.versionId}</version>
</dependency>
</dependencies>
...
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加