P
P
parkito2017-01-18 20:22:56
Java
parkito, 2017-01-18 20:22:56

What is the build error of a multi-module application?

Hello.
I am compiling an application in which there are 3 Parent modules

<groupId>com.ChatRoom</groupId>
    <artifactId>ChatRoom</artifactId>
    <packaging>pom</packaging>
    <version>1.0</version>
    <name>ChatRoom Maven Webapp</name>
    <url>http://maven.apache.org</url>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.3.RELEASE</version>
    </parent>

    <modules>
        <module>soapService</module>
        <module>portalService</module>
        <module>webResolver</module>
    </modules>

    <dependencies>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-cache</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <properties>
        <java-version>1.8</java-version>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <start-class>resolvers.Application</start-class>
    </properties>

</project>

module 1
<parent>
        <groupId>com.ChatRoom</groupId>
        <artifactId>ChatRoom</artifactId>
        <version>1.0</version>
    </parent>

    <groupId>com.MVC</groupId>
    <artifactId>MVC</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>
    <name>MVC</name>
    <description>MVC service</description>

    <dependencies>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>${hibernate.version}</version>
        </dependency>

        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>5.3.4.Final</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.40</version>
        </dependency>

        <dependency>
            <groupId>org.dbunit</groupId>
            <artifactId>dbunit</artifactId>
            <version>2.5.3</version>
        </dependency>

        <dependency>
            <groupId>org.unitils</groupId>
            <artifactId>unitils-database</artifactId>
            <version>3.4.2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.unitils</groupId>
            <artifactId>unitils-dbunit</artifactId>
            <version>3.4.2</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <java.version>1.8</java.version>
        <hibernate.version>5.2.4.Final</hibernate.version>
        <start-class>resolvers.Application</start-class>
    </properties>

</project>

module 2
<parent>
        <groupId>com.ChatRoom</groupId>
        <artifactId>ChatRoom</artifactId>
        <version>1.0</version>
    </parent>

    <groupId>com.SOAP</groupId>
    <artifactId>SOAP</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>
    <name>SOAP</name>
    <description>SOAP service</description>

    <dependencies>

        <dependency>
            <groupId>wsdl4j</groupId>
            <artifactId>wsdl4j</artifactId>
            <version>1.6.1</version>
        </dependency>

        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.2.12</version>
        </dependency>


        <dependency>
            <groupId>org.springframework.ws</groupId>
            <artifactId>spring-ws-core</artifactId>
            <version>2.4.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>com.MVC</groupId>
            <artifactId>MVC</artifactId>
            <version>1.0</version>
        </dependency>

    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <properties>
        <java-version>1.8</java-version>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <start-class>resolvers.Application</start-class>
    </properties>
</project>

module 3
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <parent>
        <artifactId>ChatRoom</artifactId>
        <groupId>com.ChatRoom</groupId>
        <version>1.0</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>
    <artifactId>Web-Resolver</artifactId>
    <packaging>war</packaging>
    <name>Web-Resolver module</name>
    <url>http://maven.apache.org</url>

    <dependencies>

        <dependency>
            <groupId>com.MVC</groupId>
            <artifactId>MVC</artifactId>
            <version>1.0</version>
        </dependency>

        <dependency>
            <groupId>com.SOAP</groupId>
            <artifactId>SOAP</artifactId>
            <version>1.0</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>


    </dependencies>

    <build>
        <finalName>Web-Resolver</finalName>
    </build>

    <properties>
        <java-version>1.8</java-version>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <cxf.version>3.0.2</cxf.version>
        <cxf.scope>compile</cxf.scope>
        <jackson.databind-version>2.8.5</jackson.databind-version>
    </properties>

</project>

Module 2 depends on module 1.
When I build an application with maven, it is the second module that is not assembled. It points to those classes that have dependencies on the first module
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project SOAP: Compilation failure: Compilation failure:
[ERROR] /C:/Users/parkito/GitHub/RooMMate/Spring/soapService/src/main/java/com/concretepage/UserUtility.java:[4,27] package com.portal.entities does not exist
[ERROR] /C:/Users/parkito/GitHub/RooMMate/Spring/soapService/src/main/java/com/concretepage/UserUtility.java:[5,29] package com.portal.exceptions does not exist
[ERROR] /C:/Users/parkito/GitHub/RooMMate/Spring/soapService/src/main/java/com/concretepage/UserUtility.java:[6,31] package com.portal.services.api does not exist
[ERROR] /C:/Users/parkito/GitHub/RooMMate/Spring/soapService/src/main/java/com/concretepage/UserUtility.java:[17,13] cannot find symbol

And then issues an exception
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project SOAP: Compilatio
n failure
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)

What am I doing wrong? Why does this conflict arise in maven?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
Zakharov Alexander, 2017-01-18
@AlexZaharow

I have not worked with modules for a long time, but maybe in this case the error is not in modularity? In practice, maven takes dependencies from the repository when building. First, the local repository is checked, if not found, then it goes to the global one (it is possible that you did not configure the corporate one to deploy to it). But still issue the "mvn install" command for module 1 to put module 1 in the local repository. Now, when building module 2, maven will find module 1 in the local repository (in theory). Try it.
What is the difference between “mvn deploy” to a l...
In principle, you can set module 1's pom to be put into the local repository after build. Read about build targets.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question