When you add your Spring Boot web API app to New Relic for monitoring, the “guided install” instructions for Spring Boot on Windows give three steps:
- add lines to pom
- download newrelic.yml file
- add java -javaagent:/full/path/to/newrelic.jar -jar app.jar
It’s the last step we are stuck with. We assume that the POM will cause the New Relic code/JAR to be included in the app.jar, and be on the class path. This then begs the question:
- Why do we have to add newrelic.jar and its path to the command line, if we already added it to the pom?
- Where do we get the path to the newrelic.jar from? This was presumably downloaded and installed by the new relic POM changes. How do we know where New Relic will put it?
If we have to manually put the New Relic jar somewhere in our project, why do we need to add lines to the POM?
If we have to manually download the JAR file:
- Where do we get it from (it’s not mentioned in guided install)
- Where should we put it in our project? We have src/main/java and src/main/resources in our project, with nothing else other than pom files etc. Where are we supposed to put New Relic JARs?
This the code the guided install instructions tell you to add to the POM:
<code><plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>unpack-newrelic</id>
<phase>package</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeGroupIds>com.newrelic.agent.java</includeGroupIds>
<includeArtifactIds>newrelic-java</includeArtifactIds>
<!-- you can optionally exclude files -->
<!-- <excludes>**/newrelic.yml</excludes> -->
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</code>
<code><plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>unpack-newrelic</id>
<phase>package</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeGroupIds>com.newrelic.agent.java</includeGroupIds>
<includeArtifactIds>newrelic-java</includeArtifactIds>
<!-- you can optionally exclude files -->
<!-- <excludes>**/newrelic.yml</excludes> -->
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</code>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.1.1</version>
<executions>
<execution>
<id>unpack-newrelic</id>
<phase>package</phase>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeGroupIds>com.newrelic.agent.java</includeGroupIds>
<includeArtifactIds>newrelic-java</includeArtifactIds>
<!-- you can optionally exclude files -->
<!-- <excludes>**/newrelic.yml</excludes> -->
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<code><dependency>
<groupId>com.newrelic.agent.java</groupId>
<artifactId>newrelic-java</artifactId>
<version>8.12.0</version>
<scope>provided</scope>
<type>zip</type>
</dependency>
</code>
<code><dependency>
<groupId>com.newrelic.agent.java</groupId>
<artifactId>newrelic-java</artifactId>
<version>8.12.0</version>
<scope>provided</scope>
<type>zip</type>
</dependency>
</code>
<dependency>
<groupId>com.newrelic.agent.java</groupId>
<artifactId>newrelic-java</artifactId>
<version>8.12.0</version>
<scope>provided</scope>
<type>zip</type>
</dependency>