简体   繁体   中英

Multimodule Spring project with Maven

I am trying to build an app with multimodule architecture, where I have the following modules:

  • app (with the controllers)
  • persistence (where I keep all entities and repos)
  • domain (pure Java-module)
  • a parent module that combines all these modules, but it has no code, only the pom-file and properties.

How do I organize the project in order to have shared app-properties in the parent-module? And should the persistency module have spring-build plugin? Cause at the moment no module sees the properties of the parent.

Technically it is possible to force pom -module to package artifacts , in your case that would be something like:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <executions>
                <execution>
                    <phase>process-resources</phase>
                    <goals>
                        <goal>resources</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                    <configuration>
                        <classifier>configs</classifier>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

However in that case child modules inherit build configuration from parent, so you will need to disable configuration of maven-jar-plugin in child modules. It is better to create sibling module rather than solving maven puzzles.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM