我正在与eclipse + tomcat配置挣扎。我在云端部署了我的应用程序,但我可以离线进行一些更改(速度更快),然后部署一些有效的工作。我使用maven设置了web项目。我有2个依赖项(不提及必要的javax):org.json
和joda-time
。问题是我无法弄清楚如何下载这些依赖项。每次我想运行项目时,tomcat都无法以长堆栈跟踪开始,但我知道问题是该行:Caused by: Java.lang.NoClassDefFoundError: javax/json/JsonObject
。这意味着,依赖关系罐子不存在(我认为是int WEB-INF/lib
)。我在项目> maven->更新项目上尝试了ppm,在服务器上测试了ppm->干净,服务器上的ppm->发布。我还检查了project-> properties->部署组件和Maven依赖关系......我已经在网上搜索了很多,而且我的想法已经用完了。谢谢你的帮助,干杯!
UPDATE 的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>
答案 0 :(得分:1)
我认为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>
(删除提供的范围)。