简体   繁体   English

Maven复制资源

[英]Maven copy resources

In the resources in the profile folder there is a configuration file, depending on the profile it should be taken and put in the resource root 在配置文件文件夹中的资源中,有一个配置文件,具体取决于应采用的配置文件并将其放在资源根目录中

Actually, what I encountered 其实我遇到的是

  1. He puts it in the project itself, and not in the original jar 他将其放在项目本身中,而不是放在原始的jar中
  2. When the second time you collect this file already comes 当您第二次收集此文件时
  3. So that the folder itself in the jar does not fall 这样罐子里的文件夹就不会掉下来

     <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> 

Tell me where I was wrong? 告诉我哪里错了? In which plugin to configure maven-ejb-plugin or maven-resources-plugin 在哪个插件中配置maven-ejb-plugin或maven-resources-plugin

I have src/main/recoursces/profile/ 我有src / main / recoursces / profile /

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

I want jar - It did not have a folder profile - and have one server.properties 我想要jar-它没有文件夹配置文件-并具有一个server.properties

I'm not sure if I understand your question. 我不确定是否理解您的问题。 I believe the resources phase package is not correct, it should be on a previous one like process-resources . 我相信资源阶段package是不正确的,它应该在上一个类似process-resources package上。

Here you have the Maven Lifecycle Reference 这里有Maven生命周期参考

process-resources : copy and process the resources into the destination directory, ready for packaging. process-resources :将资源复制并处理到目标目录中,以备打包。
package : take the compiled code and package it in its distributable format, such as a JAR. package :采用编译后的代码并将其打包为可分发格式,例如JAR。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM