spring-boot-maven-plugin and maven-dependency-plugin seems incompatible with buildpack for injecting dependency

huangapple go评论69阅读模式
英文:

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

我还尝试了以下配置,但未出现在图像中:

spring-boot-maven-plugin and maven-dependency-plugin seems incompatible with buildpack for injecting dependency
spring-boot-maven-plugin and maven-dependency-plugin seems incompatible with buildpack for injecting dependency

英文:

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:

      &lt;plugin&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
        &lt;configuration&gt;
          &lt;image&gt;
              &lt;env&gt;
                  &lt;BP_JVM_VERSION&gt;17&lt;/BP_JVM_VERSION&gt;
              &lt;/env&gt;
          &lt;/image&gt;
        &lt;/configuration&gt;
      &lt;/plugin&gt;

       &lt;plugin&gt;
        &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
        &lt;artifactId&gt;maven-dependency-plugin&lt;/artifactId&gt;
        &lt;executions&gt;
            &lt;execution&gt;
                &lt;id&gt;unpack-newrelic&lt;/id&gt;
                &lt;phase&gt;package&lt;/phase&gt;
                &lt;goals&gt;
                  &lt;goal&gt;unpack-dependencies&lt;/goal&gt;
                &lt;/goals&gt;
                &lt;configuration&gt;
                  &lt;includeGroupIds&gt;com.newrelic.agent.java&lt;/includeGroupIds&gt;
                  &lt;includeArtifactIds&gt;newrelic-java&lt;/includeArtifactIds&gt;
                &lt;/configuration&gt;
            &lt;/execution&gt;
        &lt;/executions&gt;
      &lt;/plugin&gt;

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:

spring-boot-maven-plugin and maven-dependency-plugin seems incompatible with buildpack for injecting dependency
spring-boot-maven-plugin and maven-dependency-plugin seems incompatible with buildpack for injecting dependency

答案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 &quot;NewRelic&quot; &gt; bindings/newrelic/type
$ echo &quot;my-app-name&quot; &gt; bindings/newrelic/app-name
$ echo &quot;licence key&quot; &gt; bindings/newrelic/license-key
$ tree bindings
bindings
├── newrelic
│&#160;&#160; ├── type
│&#160;&#160; └── app-name
│&#160;&#160; └── license-key

Then configure the Spring Boot Maven plugin to add the New Relic buildpack and provide the binding:

  &lt;plugin&gt;
    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
    &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;
    &lt;configuration&gt;
      &lt;image&gt;
        &lt;buildpacks&gt;
          &lt;buildpack&gt;urn:cnb:builder:paketo-buildpacks/java&lt;/buildpack&gt;
          &lt;buildpack&gt;paketobuildpacks/new-relic&lt;/buildpack&gt;
        &lt;/buildpacks&gt;
        &lt;bindings&gt;
          &lt;binding&gt;${basedir}/bindings/newrelic:/platform/bindings/newrelic&lt;/binding&gt;
        &lt;/bindings&gt;
      &lt;/image&gt;
    &lt;/configuration&gt;
  &lt;/plugin&gt;

More information on configuring the Spring Boot Maven plugin is available in the documentation.

huangapple
  • 本文由 发表于 2023年6月15日 04:26:40
  • 转载请务必保留本文链接:https://go.coder-hub.com/76477301.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定