gpt4 book ai didi

java maven eclipse tomcat 启动失败NoClassDefFoundError

转载 作者:行者123 更新时间:2023-11-28 22:53:47 34 4
gpt4 key购买 nike

我正在为 eclipse+tomcat 配置而苦恼。我在云上部署了我的应用程序,但我希望离线进行一些更改(速度更快),然后部署一些可以工作的东西。我使用 Maven 设置了 Web 项目。我有 2 个依赖项(未提及必要的 javax):org.jsonjoda-time。问题是我不知道如何下载这些依赖项。每次我想运行项目时,tomcat 都无法以长堆栈跟踪启动,但我知道问题出在那一行:Caused by: Java.lang.NoClassDefFoundError: javax/json/JsonObject。这意味着,不存在依赖项 jar(我认为是 int WEB-INF/lib)。我已经在项目->maven->更新项目上尝试过 ppm,在服务器上尝试过 ppm->clean,在服务器上尝试过 ppm-> 发布。我还检查了 project->properties->Deployment Asembly 和 Maven Dependencies 在那里......我在网上搜索了很多,但我的想法已经用完了。感谢您的帮助,干杯!

更新pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>openshifttest</groupId>
<artifactId>openshifttest</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>openshifttest</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>

<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>

<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.8.2</version>
</dependency>

</dependencies>

<profiles>
<profile>
<!-- When built in OpenShift the 'openshift' profile will be used when invoking mvn. -->
<!-- Use this profile for any OpenShift specific customization your app will need. -->
<!-- By default that is to put the resulting archive into the 'deployments' folder. -->
<!-- http://maven.apache.org/guides/mini/guide-building-for-different-environments.html -->
<id>openshift</id>
<build>
<finalName>openshifttest</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<outputDirectory>deployments</outputDirectory>
<warName>ROOT</warName>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

最佳答案

我认为tomcat可能没有提供Java EE API,请尝试更改

    <dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>

    <dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
</dependency>

(删除提供的范围)。

关于java maven eclipse tomcat 启动失败NoClassDefFoundError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32852105/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com