英文:
spring-boot-maven-plugin and maven-dependency-plugin seems incompatible with buildpack for injecting dependency
问题
从jib迁移到spring-boot-maven-plugin似乎无法找到我尝试安装的新遗迹代理。这是我的pom.xml:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<env>
<BP_JVM_VERSION>17</BP_JVM_VERSION>
</env>
</image>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<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>
</configuration>
</execution>
</executions>
</plugin>
使用dive,我能够找到代理的路径,即-javaagent:/workspace/BOOT-INF/lib/newrelic-java-8.3.0.zip
,但是当容器启动时,我收到以下消息:
代理库初始化失败:instrument
打开zip文件失败或缺少JAR清单:/workspace/BOOT-INF/lib/newrelic-java-8.3.0.zip
有人遇到类似的问题吗?
版本:
- spring-boot: 3.1
我还尝试了以下配置,但未出现在图像中:
英文:
Migrating from jib to spring-boot-maven-plugin It seems that the image is not able to find the new relic agent I am trying to install. Here is my pom.xml:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<env>
<BP_JVM_VERSION>17</BP_JVM_VERSION>
</env>
</image>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<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>
</configuration>
</execution>
</executions>
</plugin>
Using dive I am able to find the path to the agent which is -javaagent:/workspace/BOOT-INF/lib/newrelic-java-8.3.0.zip
but when the container is starting I am having the following message:
agent library failed to init: instrument
Error opening zip file or JAR manifest missing : /workspace/BOOT-INF/lib/newrelic-java-8.3.0.zip
Anyone had similar issue ?
version:
- spring-boot: 3.1
Also tried the following configuration with bindings but does not appear in the image:
答案1
得分: 2
我不确定为什么您的方法不起作用,但您可以尝试让Paketo New Relic构建包来安装和配置代理程序,这样也许会更顺利。默认情况下不包括此构建包,因此您需要配置构建以使用它。您还需要创建一个绑定以提供代理程序所需的任何配置。
对于绑定,请在项目结构的根目录中(与项目的src
目录位于同一级别)创建一个名为bindings
的目录,并在该目录中创建一些文件。type
文件是必需的,其他文件取决于您需要配置代理程序的内容:
$ mkdir -p bindings/newrelic
$ echo "NewRelic" > bindings/newrelic/type
$ echo "my-app-name" > bindings/newrelic/app-name
$ echo "licence key" > bindings/newrelic/license-key
$ tree bindings
bindings
├── newrelic
│ ├── type
│ └── app-name
│ └── license-key
然后配置Spring Boot Maven插件以添加New Relic构建包并提供绑定:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<buildpacks>
<buildpack>urn:cnb:builder:paketo-buildpacks/java</buildpack>
<buildpack>paketobuildpacks/new-relic</buildpack>
</buildpacks>
<bindings>
<binding>${basedir}/bindings/newrelic:/platform/bindings/newrelic</binding>
</bindings>
</image>
</configuration>
</plugin>
有关配置Spring Boot Maven插件的更多信息,请参阅文档。
英文:
I'm not sure why your approach isn't working, but you might have better luck letting the Paketo Buildpack for New Relic install and configure the agent for you. This buildpack is not included by default, so you'll need to configure your build to use it. You'll also need to create a binding to give the agent any configuration that it needs.
For the binding, create a bindings
directory in the root of your project structure (at the same level as the project src
directory) and create some files in that directory. The type
file is required, any others depend on what you need to configure the agent:
$ mkdir -p bindings/newrelic
$ echo "NewRelic" > bindings/newrelic/type
$ echo "my-app-name" > bindings/newrelic/app-name
$ echo "licence key" > bindings/newrelic/license-key
$ tree bindings
bindings
├── newrelic
│   ├── type
│   └── app-name
│   └── license-key
Then configure the Spring Boot Maven plugin to add the New Relic buildpack and provide the binding:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<image>
<buildpacks>
<buildpack>urn:cnb:builder:paketo-buildpacks/java</buildpack>
<buildpack>paketobuildpacks/new-relic</buildpack>
</buildpacks>
<bindings>
<binding>${basedir}/bindings/newrelic:/platform/bindings/newrelic</binding>
</bindings>
</image>
</configuration>
</plugin>
More information on configuring the Spring Boot Maven plugin is available in the documentation.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论