gpt4 book ai didi

java - 通过 'maven-assembly-plugin'打包spring boot项目时出现Directory Error

转载 作者:行者123 更新时间:2023-11-30 11:00:37 25 4
gpt4 key购买 nike

我通过'maven-assembly-plugin'打包了spring boot项目,但是我得到了目录错误。

为什么'config'文件夹在根目录,而不是在 “bth_core”目录?

这是pom.xml

<build>
<finalName>bth-core</finalName>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>

</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<configuration>
<excludes>
<exclude> **/assemble/**</exclude>
<exclude> **/properties/** </exclude>
<exclude> **/log4j.properties </exclude>
<exclude> **/script/**</exclude>
<exclude> **/spring/**</exclude>
<exclude> **/sqlmap/** </exclude>
<exclude> **/jobs/** </exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions> <!-- mvn assembly:assembly-->
<execution>
<id>make-zip</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/resources/assemble/assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

这里是 assembly.xml

<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>${mavenDir}-assembly</id>
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.basedir}/src/main/resources</directory>
<includes>
<include>**/*.xml</include>
<include>log4j.properties</include>
<!-- <include>**/properties/${mavenDir}/**</include> -->
</includes>
<excludes>
<exclude>**/assemble/**</exclude>
<exclude>**/script/**</exclude>
<exclude>**/properties/*.properties</exclude>
<exclude>**/key/**</exclude>
</excludes>
<outputDirectory>config</outputDirectory>
</fileSet>
<!-- <fileSet>
<directory>${project.basedir}/src/main/resources/properties/${mavenDir}</directory>
<outputDirectory>config/properties/</outputDirectory>
</fileSet> -->
<fileSet>
<directory>${project.basedir}/src/main/log</directory>
<outputDirectory>log</outputDirectory>
</fileSet>

<fileSet>
<directory>${project.basedir}/src/main/resources/script</directory>
<includes>
<include>startup.sh</include>
</includes>
<fileMode>0755</fileMode>
<outputDirectory>/</outputDirectory>
<lineEnding>unix</lineEnding>
</fileSet>
</fileSets>
<files>
<file>
<source>${project.basedir}/src/main/resources/script/conf/setenv-${mavenDir}.conf</source>
<outputDirectory>config</outputDirectory>
<destName>setenv.conf</destName>
<lineEnding>unix</lineEnding>
</file>
</files>
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
<excludes>
<exclude>org.apache.maven:*</exclude>
<exclude>org.codehaus.plexus:*</exclude>
<exclude>org.apache.maven.wagon:*</exclude>
<exclude>org.apache.maven.surefire:*</exclude>
<exclude>org.apache.maven.plugins:*</exclude>
<exclude>junit:*</exclude>
<!-- <exclude>log4j:*</exclude> -->
</excludes>
</dependencySet>
</dependencySets>

最佳答案

如果你绝对需要,这里是我如何成功地将 maven assembly 插件与 spring boot maven 插件一起使用:

<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>assembly_descriptor.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

HTH:)

关于java - 通过 'maven-assembly-plugin'打包spring boot项目时出现Directory Error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31446535/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com