spring boot package does not exist error

Viewed 16837

I'm compiling my project with mvn clean package, and failed with package does not exist.

The detail command:

  • Get the jar file target/xxxx.jar by running mvn clean package in source project.
  • install this jar file by running mvn install:install-file -Dfile=lib/xxxx.jar -DgroupId=com.company -DartifactId=source-package-name -Dversion=1.0.0 -Dpackaging=jar
  • add code to target project, which will use some functions in source project
  • compile target project by running mvn clean package, and it just failed with package does not exist

here is the source project pom.xml

<?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.company</groupId>
    <artifactId>source-package-name</artifactId>
    <version>1.0.0</version>
    <packaging>jar</packaging>

    <name>source-package-name</name>
    <description>xxxx</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.3.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>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <argLine>-Xmx6144m</argLine>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

here is the target project pom.xml

<?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.company</groupId>
    <artifactId>target-package-name</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>target-package-name</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <jdk.version>1.7</jdk.version>
        <smartv-common.version>0.3.5s</smartv-common.version>
        <spring.version>3.0.5.RELEASE</spring.version>
    </properties>

    <dependencies>

    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <excludes>
                    <!-- Exclude those since they are copied from the profile folder for 
                        the build -->
                    <exclude>system.properties</exclude>
                </excludes>
                <filtering>false</filtering>
            </resource>
        </resources>

        <finalName>xxxxx</finalName>
        <!-- Set a compiler level -->

        <extensions>
            <extension>
                <groupId>kr.motd.maven</groupId>
                <artifactId>os-maven-plugin</artifactId>
                <version>1.4.1.Final</version>
            </extension>
        </extensions>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>${jdk.version}</source>
                    <target>${jdk.version}</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.6</version>
                <configuration>

                    <!-- http://maven.apache.org/plugins/maven-war-plugin/examples/adding-filtering-webresources.html 
                        http://stackoverflow.com/questions/12729513/how-to-overwrite-files-in-the-war-file-during-maven-build -->
                    <webResources>
                        <!-- Resources from the activated profile folder -->
                        <resource>
                            <targetPath>WEB-INF/classes/</targetPath>
                            <includes>
                                <include>system.properties</include>
                            </includes>
                        </resource>
                    </webResources>

                </configuration>

            </plugin>

        </plugins>
    </build>

</project>
1 Answers
Related