我终于能够构建我的项目了,但是当我试图访问战争时它出错了。我将通过Anghel Leonard的Apress书籍 Pro Hibernate和MongoDB (找到here),但书中的例子不会产生任何结果。
的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>
<packaging>war</packaging>
<groupId>com.ogm</groupId>
<artifactId>Maven_HOGM</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.hibernate.ogm</groupId>
<artifactId>hibernate-ogm-core</artifactId>
<version>4.0.0.Beta2</version>
</dependency>
<dependency>
<groupId>org.hibernate.ogm</groupId>
<artifactId>hibernate-ogm-mongodb</artifactId>
<version>4.0.0.Beta1</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.orbit</groupId>
<artifactId>javax.servlet</artifactId>
<version>3.0.0.v201112011016</version>
</dependency>
</dependencies>
<build>
<directory>c:\dev\Hibernate_OGM</directory>
<defaultGoal>dependency:copy-dependencies</defaultGoal>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>tomcat-maven-plugin</artifactId>
<configuration>
<url>http://127.0.0.1:8080/manager</url>
<server>TomcatServer</server>
<path>/FileUpload</path>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
我输入
mvn tomcat:run
我收到此错误
例外
javax.servlet.ServletException:java.lang.LinkageError:loader 约束违规:loader(实例) org / apache / jasper / servlet / JasperLoader)先前已启动加载 对于名称为“javax / servlet / http / HttpServletRequest”的其他类型 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:268) javax.servlet.http.HttpServlet.service(HttpServlet.java:717)root 原因
java.lang.LinkageError:加载器约束违规:loader(实例 of org / apache / jasper / servlet / JasperLoader)之前发起的 加载具有名称的其他类型 “的javax / servlet的/ HTTP / HttpServletRequest的” java.lang.Class.getDeclaredMethods0(本机方法) java.lang.Class.privateGetDeclaredMethods(Class.java:2521) java.lang.Class.getDeclaredMethods(Class.java:1845) org.apache.catalina.util.DefaultAnnotationProcessor.processAnnotations(DefaultAnnotationProcessor.java:226) org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:148) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:329) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260) javax.servlet.http.HttpServlet.service(HttpServlet.java:717)