When maven builds the jar package, the local jar package is missing

Recently, I have deployed in the development environment through Docker + harbor + kuboard, and encountered a problem. The project is running normally in the local idea, but kuboard keeps reporting an error and restarting.

BACK-OFF RESTARTING FAILED CONTAINER

By checking the kuboard log, it was found that a local database connection driver was missing when running the container startup project.
Then check the pom file in the project, everything feels normal at first. The pom configuration is as follows:

        <dependency>
            <groupId>com.dm</groupId>
            <artifactId>DmJdbcDriver</artifactId>
            <version>18</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/src/main/resources/lib/DmJdbcDriver-18.jar</systemPath>
        </dependency>
        ………

  <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <includeSystemScope>true</includeSystemScope>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
  <build/>

The database driver is placed in the lib folder in the resources directory and is directly specified locally in the dependency. includeSystemScopeLater, local jar packages will be supported by declaring them in the plugin maven tool .
But no matter how I repackage it later, I get the same error.
Later I found the following paragraph in someone else's code:

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <includeSystemScope>true</includeSystemScope>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>

        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
            <resource>
                <directory>lib</directory>
                <targetPath>BOOT-INF/lib/</targetPath>
                <includes>
                    <include>*.jar</include>
                </includes>
            </resource>
        </resources>
    </build>

Then resourcesI transplanted this paragraph to my builddownload. After repackaging, the error disappeared and the project ran successfully, but I still don't understand the specific reason. Then comment out this code, delete the local target, and mvn clean packagetry again to check in the jar package to see if it has been imported, but this time there is already a local jar package in the package, and no error is reported, the problem cannot be solved reproduced. Although the problem was solved vaguely, this kind of unclear reason is really annoying. I hope that I can find the reason next time I encounter similar problems.

おすすめ

転載: blog.csdn.net/qq_42740899/article/details/131378074