Compile project that references installed project












0















I have a library module that I created through Maven, there is pom.xml what get dependencies:



<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.18.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<groupId>com.example.library</groupId>
<artifactId>commons</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>

<name>commons</name>
<description>common dependencies library</description>

<properties>
<java.version>1.8</java.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>


With the above pom, I successfully installed it into the local maven repository by using mvn install.



In another project my-service, which uses this installed library, within the IntelliJ IDEA, it is fine compiling and running. There is the pom.xml for the my-service



<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>my-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>my-service</name>
<description>My Services</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.18.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>

<dependencies>
<!-- other dependencies ... -->

<dependency>
<groupId>com.example.library</groupId>
<artifactId>commons</artifactId>
<version>1.0.0</version>
</dependency>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>


However, when running with mvn compile, I got the following errors:



[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project my-service: Compilation failure: Compilation failure:
[ERROR] /Users/doe/IdeaProjects/my-service/src/main/java/com/example/myservice/configs/WebSecurityConfig.java:[3,45] package com.example.library.commons.filters does not exist
[ERROR] /Users/doe/IdeaProjects/my-service/src/main/java/com/example/myservice/configs/WebSecurityConfig.java:[17,13] cannot find symbol
[ERROR] symbol: class SessionFilter
[ERROR] location: class com.example.myservice.configs.WebSecurityConfig
[ERROR] /Users/doe/IdeaProjects/my-service/src/main/java/com/example/myservice/configs/WebSecurityConfig.java:[19,36] cannot find symbol
[ERROR] symbol: class SessionFilter
[ERROR] location: class com.example.myservice.configs.WebSecurityConfig


The library project is created as part of the IntelliJ IDEA module within the same project as the my-service module. I guess the IntelliJ IDEA knows how to internally references module to compile the depending modules, but with Maven, it is a different story.



My goal is to compile and package the my-service module as a single jar that includes the commons library module. Now I can't even get it to compile with Maven, what did I do wrong?



Apache Maven version 3.3.9 . Operating system: OS X.










share|improve this question





























    0















    I have a library module that I created through Maven, there is pom.xml what get dependencies:



    <?xml version="1.0" encoding="UTF-8"?>
    <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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.18.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <groupId>com.example.library</groupId>
    <artifactId>commons</artifactId>
    <version>1.0.0</version>
    <packaging>jar</packaging>

    <name>commons</name>
    <description>common dependencies library</description>

    <properties>
    <java.version>1.8</java.version>
    </properties>

    <dependencies>
    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <build>
    <plugins>
    <plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    </plugin>
    </plugins>
    </build>

    </project>


    With the above pom, I successfully installed it into the local maven repository by using mvn install.



    In another project my-service, which uses this installed library, within the IntelliJ IDEA, it is fine compiling and running. There is the pom.xml for the my-service



    <?xml version="1.0" encoding="UTF-8"?>
    <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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example</groupId>
    <artifactId>my-service</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>my-service</name>
    <description>My Services</description>

    <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.18.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <java.version>1.8</java.version>
    </properties>

    <dependencies>
    <!-- other dependencies ... -->

    <dependency>
    <groupId>com.example.library</groupId>
    <artifactId>commons</artifactId>
    <version>1.0.0</version>
    </dependency>

    <build>
    <plugins>
    <plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    </plugin>
    </plugins>
    </build>
    </project>


    However, when running with mvn compile, I got the following errors:



    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project my-service: Compilation failure: Compilation failure:
    [ERROR] /Users/doe/IdeaProjects/my-service/src/main/java/com/example/myservice/configs/WebSecurityConfig.java:[3,45] package com.example.library.commons.filters does not exist
    [ERROR] /Users/doe/IdeaProjects/my-service/src/main/java/com/example/myservice/configs/WebSecurityConfig.java:[17,13] cannot find symbol
    [ERROR] symbol: class SessionFilter
    [ERROR] location: class com.example.myservice.configs.WebSecurityConfig
    [ERROR] /Users/doe/IdeaProjects/my-service/src/main/java/com/example/myservice/configs/WebSecurityConfig.java:[19,36] cannot find symbol
    [ERROR] symbol: class SessionFilter
    [ERROR] location: class com.example.myservice.configs.WebSecurityConfig


    The library project is created as part of the IntelliJ IDEA module within the same project as the my-service module. I guess the IntelliJ IDEA knows how to internally references module to compile the depending modules, but with Maven, it is a different story.



    My goal is to compile and package the my-service module as a single jar that includes the commons library module. Now I can't even get it to compile with Maven, what did I do wrong?



    Apache Maven version 3.3.9 . Operating system: OS X.










    share|improve this question



























      0












      0








      0








      I have a library module that I created through Maven, there is pom.xml what get dependencies:



      <?xml version="1.0" encoding="UTF-8"?>
      <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/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>

      <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>1.5.18.RELEASE</version>
      <relativePath/> <!-- lookup parent from repository -->
      </parent>

      <groupId>com.example.library</groupId>
      <artifactId>commons</artifactId>
      <version>1.0.0</version>
      <packaging>jar</packaging>

      <name>commons</name>
      <description>common dependencies library</description>

      <properties>
      <java.version>1.8</java.version>
      </properties>

      <dependencies>
      <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
      </dependency>
      <build>
      <plugins>
      <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
      </plugins>
      </build>

      </project>


      With the above pom, I successfully installed it into the local maven repository by using mvn install.



      In another project my-service, which uses this installed library, within the IntelliJ IDEA, it is fine compiling and running. There is the pom.xml for the my-service



      <?xml version="1.0" encoding="UTF-8"?>
      <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/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>

      <groupId>com.example</groupId>
      <artifactId>my-service</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <packaging>jar</packaging>

      <name>my-service</name>
      <description>My Services</description>

      <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>1.5.18.RELEASE</version>
      <relativePath/> <!-- lookup parent from repository -->
      </parent>

      <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
      <java.version>1.8</java.version>
      </properties>

      <dependencies>
      <!-- other dependencies ... -->

      <dependency>
      <groupId>com.example.library</groupId>
      <artifactId>commons</artifactId>
      <version>1.0.0</version>
      </dependency>

      <build>
      <plugins>
      <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
      </plugins>
      </build>
      </project>


      However, when running with mvn compile, I got the following errors:



      [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project my-service: Compilation failure: Compilation failure:
      [ERROR] /Users/doe/IdeaProjects/my-service/src/main/java/com/example/myservice/configs/WebSecurityConfig.java:[3,45] package com.example.library.commons.filters does not exist
      [ERROR] /Users/doe/IdeaProjects/my-service/src/main/java/com/example/myservice/configs/WebSecurityConfig.java:[17,13] cannot find symbol
      [ERROR] symbol: class SessionFilter
      [ERROR] location: class com.example.myservice.configs.WebSecurityConfig
      [ERROR] /Users/doe/IdeaProjects/my-service/src/main/java/com/example/myservice/configs/WebSecurityConfig.java:[19,36] cannot find symbol
      [ERROR] symbol: class SessionFilter
      [ERROR] location: class com.example.myservice.configs.WebSecurityConfig


      The library project is created as part of the IntelliJ IDEA module within the same project as the my-service module. I guess the IntelliJ IDEA knows how to internally references module to compile the depending modules, but with Maven, it is a different story.



      My goal is to compile and package the my-service module as a single jar that includes the commons library module. Now I can't even get it to compile with Maven, what did I do wrong?



      Apache Maven version 3.3.9 . Operating system: OS X.










      share|improve this question
















      I have a library module that I created through Maven, there is pom.xml what get dependencies:



      <?xml version="1.0" encoding="UTF-8"?>
      <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/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>

      <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>1.5.18.RELEASE</version>
      <relativePath/> <!-- lookup parent from repository -->
      </parent>

      <groupId>com.example.library</groupId>
      <artifactId>commons</artifactId>
      <version>1.0.0</version>
      <packaging>jar</packaging>

      <name>commons</name>
      <description>common dependencies library</description>

      <properties>
      <java.version>1.8</java.version>
      </properties>

      <dependencies>
      <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
      </dependency>
      <build>
      <plugins>
      <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
      </plugins>
      </build>

      </project>


      With the above pom, I successfully installed it into the local maven repository by using mvn install.



      In another project my-service, which uses this installed library, within the IntelliJ IDEA, it is fine compiling and running. There is the pom.xml for the my-service



      <?xml version="1.0" encoding="UTF-8"?>
      <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/xsd/maven-4.0.0.xsd">
      <modelVersion>4.0.0</modelVersion>

      <groupId>com.example</groupId>
      <artifactId>my-service</artifactId>
      <version>0.0.1-SNAPSHOT</version>
      <packaging>jar</packaging>

      <name>my-service</name>
      <description>My Services</description>

      <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>1.5.18.RELEASE</version>
      <relativePath/> <!-- lookup parent from repository -->
      </parent>

      <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
      <java.version>1.8</java.version>
      </properties>

      <dependencies>
      <!-- other dependencies ... -->

      <dependency>
      <groupId>com.example.library</groupId>
      <artifactId>commons</artifactId>
      <version>1.0.0</version>
      </dependency>

      <build>
      <plugins>
      <plugin>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
      </plugins>
      </build>
      </project>


      However, when running with mvn compile, I got the following errors:



      [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project my-service: Compilation failure: Compilation failure:
      [ERROR] /Users/doe/IdeaProjects/my-service/src/main/java/com/example/myservice/configs/WebSecurityConfig.java:[3,45] package com.example.library.commons.filters does not exist
      [ERROR] /Users/doe/IdeaProjects/my-service/src/main/java/com/example/myservice/configs/WebSecurityConfig.java:[17,13] cannot find symbol
      [ERROR] symbol: class SessionFilter
      [ERROR] location: class com.example.myservice.configs.WebSecurityConfig
      [ERROR] /Users/doe/IdeaProjects/my-service/src/main/java/com/example/myservice/configs/WebSecurityConfig.java:[19,36] cannot find symbol
      [ERROR] symbol: class SessionFilter
      [ERROR] location: class com.example.myservice.configs.WebSecurityConfig


      The library project is created as part of the IntelliJ IDEA module within the same project as the my-service module. I guess the IntelliJ IDEA knows how to internally references module to compile the depending modules, but with Maven, it is a different story.



      My goal is to compile and package the my-service module as a single jar that includes the commons library module. Now I can't even get it to compile with Maven, what did I do wrong?



      Apache Maven version 3.3.9 . Operating system: OS X.







      maven intellij-idea






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 31 '18 at 3:58









      Do Nhu Vy

      17.1k1591130




      17.1k1591130










      asked Dec 31 '18 at 3:30









      Zhenyang HuaZhenyang Hua

      1,43721628




      1,43721628
























          1 Answer
          1






          active

          oldest

          votes


















          0














          It turns out the Spring-boot-maven plugin is not needed in the library project because a library doesn't need to produce an executable ueber jar. After removing the plugin, it compiles successfully.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53983313%2fcompile-project-that-references-installed-project%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            It turns out the Spring-boot-maven plugin is not needed in the library project because a library doesn't need to produce an executable ueber jar. After removing the plugin, it compiles successfully.






            share|improve this answer




























              0














              It turns out the Spring-boot-maven plugin is not needed in the library project because a library doesn't need to produce an executable ueber jar. After removing the plugin, it compiles successfully.






              share|improve this answer


























                0












                0








                0







                It turns out the Spring-boot-maven plugin is not needed in the library project because a library doesn't need to produce an executable ueber jar. After removing the plugin, it compiles successfully.






                share|improve this answer













                It turns out the Spring-boot-maven plugin is not needed in the library project because a library doesn't need to produce an executable ueber jar. After removing the plugin, it compiles successfully.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 31 '18 at 3:55









                Zhenyang HuaZhenyang Hua

                1,43721628




                1,43721628






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53983313%2fcompile-project-that-references-installed-project%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Angular Downloading a file using contenturl with Basic Authentication

                    Can't read property showImagePicker of undefined in react native iOS

                    Olmecas