How to make Maven resource file copied to WEB-INF / lib directory?

I use NewRelic for monitoring. I want Maven to pack the newrelic.jar and newrelic.yaml files into my WEB-INF/lib inside the war file. There is no problem with newrelic.jar, as it is a simple dependency, but newrelic.yaml is a resource file. It is located in the resource directory. I want Maven (military plugin) to copy it to WEB-INF/lib when packing war.

Thanks.

Alex

+6
source share
3 answers

So far, I agree with @matt b that this is strange, here is what you can do:

Try changing the configuration of the maven war plugin to enable webResource:

  <configuration> <webResources> <resource> <directory>pathtoyaml</directory> <includes> <include>**/*.yaml</include> <includes> <targetPath>WEB-INF/lib</targetPath> </resource> </webResources> </configuration> 

The catalog refers to pom.xml. See the plugin documentation for more details.

+9
source

You can also specify a large configuration for the new Relic agent, including the location of the configuration file through the checkboxes passed to the java command. In this case, it is something like:

-Dnewrelic.config.file = / etc. /newrelic.yml

(well, thatโ€™s exactly true, but you need to specify any path you need if itโ€™s not.)

+4
source
  • You should try adding the .yaml file to newrelic.jar resources, later you can access it through the classpath.
  • Or try changing / overriding the target of the build.xml assembly by adding something like <copy file = ". Yaml" todir = "WEB-INF / lib" / ">

Try googling for more information on modifying the build.xml file.

0
source

Source: https://habr.com/ru/post/900687/


All Articles