0

根据Spring Boot 1.2.3 Reference Docs。启用 jolokia 似乎就像添加以下 Maven 依赖项一样简单:

<dependency>
    <groupId>org.jolokia</groupId>
    <artifactId>jolokia-core</artifactId>
 </dependency>

虽然这确实适用于打包为胖 jar 的 Spring Boot 应用程序,但当打包为 WAR 文件时,我无法让它工作。

根本原因似乎是:

Caused by: java.lang.ClassNotFoundException: org.json.simple.JSONAware

我将 STS 用于开发目的并部署到嵌入式关键 tc Server 3.1。包含 的依赖项(json-simple-1.1.1.jar)org.json.simple.JSONAware 确实出现在 Maven 依赖项节点下,所以我不确定问题是什么。

4

2 回答 2

1

因此,当我撰写问题时,我偶然发现了一个至少似乎对我有用的解决方案:

我查看了有效的 POM,发现了这个依赖声明:

      <dependency>
        <groupId>com.googlecode.json-simple</groupId>
        <artifactId>json-simple</artifactId>
        <version>1.1.1</version>
        <optional>true</optional>
      </dependency>

因此,由于缺乏更好的选择,我明确声明了以下依赖项

<dependency>
    <groupId>com.googlecode.json-simple</groupId>
    <artifactId>json-simple</artifactId>
    <optional>false</optional>
  </dependency>

向元素添加false似乎是必要的。<optional>

现在我可以通过以下网址访问 jolokia:

http://<myurl>:<myport>/<appcontext>/jolokia
于 2015-05-18T14:58:19.703 回答
1

查看 1.4.4,这似乎已修复:

<dependency>
  <!-- Make json-simple non-optional. 
       It is marked optional in boot-dependencies, but required by jolokia-core.
       Without this fix it would be missing when used war-packaging. -->
  <groupId>com.googlecode.json-simple</groupId>
  <artifactId>json-simple</artifactId>
  <optional>false</optional>
</dependency>

然而,我在 JBoss 中看到了类似的问题。

于 2016-12-17T14:35:37.843 回答