[英]java maven eclipse tomcat failed to start NoClassDefFoundError
我正在為eclipse + tomcat配置苦苦掙扎。 我將我的應用程序部署在雲上,但我希望離線進行一些更改(速度更快),然后部署一些可行的方法。 我已經使用Maven設置了Web項目。 我有2個依賴項(未提及基本的javax): org.json
和joda-time
。 問題是我不知道如何下載那些依賴項。 每次我要運行項目時,tomcat都不會從長堆棧跟蹤開始,但是我知道問題出在那行: Caused by: Java.lang.NoClassDefFoundError: javax/json/JsonObject
。 這意味着,依賴項jar不存在(我認為是int WEB-INF/lib
)。 我已經在項目-> maven->更新項目上嘗試過ppm,在服務器上->清除了ppm,在服務器上->發布中了ppm。 我還檢查了project-> properties-> Deployment Assembly和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>
(刪除提供的范圍)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.