gpt4 book ai didi

java - Maven复制资源

转载 作者:太空宇宙 更新时间:2023-11-04 11:07:56 24 4
gpt4 key购买 nike

在配置文件文件夹中的资源中,有一个配置文件,具体取决于应采用的配置文件并将其放入资源根目录中

其实我也遇到过

  1. 他把它放在项目本身中,而不是原来的 jar 中
  2. 当您第二次收集该文件时
  3. 这样 jar 中的文件夹本身就不会掉落

    <plugins>
    <plugin>
    <artifactId>maven-resources-plugin</artifactId>
    <version>${maven-resources-plugin.version}</version>
    <executions>
    <execution>
    <id>copy-properties</id>
    <phase>package</phase>
    <goals>
    <goal>copy-resources</goal>
    </goals>
    <configuration>
    <outputDirectory>${basedir}/src/main/resources</outputDirectory>
    <resources>
    <resource>
    <directory>${basedir}/src/main/resources/profile/${profile.dir}</directory>
    <includes>
    <include>server.properties</include>
    </includes>
    </resource>
    </resources>
    </configuration>
    </execution>
    </executions>
    </plugin>

    <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-ejb-plugin</artifactId>
    <version>${maven-ejb-plugin.version}</version>
    <configuration>
    <filterDeploymentDescriptor>true</filterDeploymentDescriptor>
    <archive>
    <manifest>
    <addClasspath>true</addClasspath>
    </manifest>
    <addMavenDescriptor>false</addMavenDescriptor>
    </archive>
    <ejbVersion>3.0</ejbVersion>
    </configuration>
    </plugin>
    </plugins>

请告诉我哪里错了?在哪个插件中配置maven-ejb-plugin或maven-resources-plugin

我有src/main/recoursces/profile/

  • serverA/server.properties
  • serverB/server.properties
  • serverC/server.properties

我想要 jar - 它没有文件夹配置文件- 并且拥有一个 server.properties

最佳答案

我不确定我是否理解你的问题。我认为资源阶段package不正确,它应该位于前一个阶段,例如process-resources

这里有Maven Lifecycle Reference

process-resources:将资源复制并处理到目标目录中,准备打包。
打包:获取已编译的代码并将其打包为其可分发的格式,例如 JAR。

关于java - Maven复制资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46300470/

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