Spring Boot + newRelic

1.6k views Asked by At

Is there any links that shows a demo of spring boot+ newRelic+ Maven. I would like to try integrate both to try and test a sample app for checking newRelic feature.

2

There are 2 answers

0
dmytro On

What about this example project?

Author added NewRelic dependency:

<dependency>
        <groupId>com.newrelic.agent.java</groupId>
        <artifactId>newrelic-agent</artifactId>
        <version>3.21.0</version>
</dependency>

Unpacked dependency to have all files in jar:

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <version>2.10</version>
            <executions>
                <execution>
                    <phase>prepare-package</phase>
                    <goals>
                        <goal>unpack-dependencies</goal>
                    </goals>
                    <configuration>
                        <includeArtifactIds>newrelic-agent</includeArtifactIds>
                        <outputDirectory>${project.build.outputDirectory}</outputDirectory>
                    </configuration>
                </execution>
            </executions>
</plugin>

Extended maven jar plugin config, to have important attributes in place:

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-jar-plugin</artifactId>
   <version>2.5</version>
   <configuration>
     <archive>
       <manifestEntries>
         <Premain-Class>com.newrelic.bootstrap.BootstrapAgent</Premain-Class>
         <Can-Redefine-Classes>true</Can-Redefine-Classes>
         <Can-Retransform-Classes>true</Can-Retransform-Classes>
       </manifestEntries>
     </archive>
   </configuration>
</plugin>

Pointed out main class of the app:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
    <mainClass>com.kubrynski.blog.newrelic.SpringBootNewRelicApplication</mainClass>
    </configuration>
</plugin>
0
Jeevan Sunkersett On

Did the packaged jar (springBoot + newRelic) work for you.

In my opinion it will NOT work. As the packaged jar contains newRelic.jar inside a Zip (which is in /BOOT-INF/lib) and not simply inside /BOOT-INF/lib like other dependencies.

Please see here

thank you