部署问题,class 即使在 pom 中也找不到

Deploymennt issues, class not found even if in pom

当我尝试 运行 我的应用程序时,出现以下错误消息:

cannot Deploy pro_jpa
deploy is failing=Error occurred during deployment: Exception while deploying the app [pro_jpa] : java.lang.NoClassDefFoundError: com/google/common/cache/CacheLoader. Please see server.log for more details.

所以我将其添加到我的 pom 中:

<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>10.0.1</version>
    </dependency>

但它没有解决问题,即使它应该将所需的 jar 添加到应用程序。

我也尝试将 guava.jar 添加到服务器库,但它没有任何改变。

如果有人有想法谢谢。

将运行时范围添加到 pom.xml 中的依赖项,以使其在运行时可用:

<scope>runtime</scope>

当我使用 2.3 版的网络应用程序时,我不再有这个问题,它只在我使用 3.0 版时出现。 我正在使用 BoneCP 和 glassfish,所以问题可能来自于它。 为了解决这个问题,我需要将 jar 添加到 glassfish 中的域本身: glassfish5\glassfish\domains[域名]\lib\ext

我以这个罐子结束:

  • bonecp-0.8.0-rc1.jar
  • guava-29.0-jre.jar
  • mysql-连接器-java-8.0.20.jar
  • slf4j-api-1.7.30.jar