0

我正在尝试将我的项目从使用外部 jar 转换为 maven。我已经在 Eclipse 中安装了 m2e 插件。但是我无法正确配置它。我已经基于外部 jar 生成了一个 pom.xml 文件,但是有一个冲突 jar - spring-orm-3.2.1.RELEASE.jar (它在列表中出现了两次,可能是重复的?)。然后我从 /WEB-INF/lib 目录中删除了 jar,并尝试将项目部署到 Tomcat。当我在 pom.xml Overview 'jar' 中选择包装时,我得到:

    2013-03-09 04:35:05 org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/home/apm/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/keepGeo/WEB-INF/lib/tomcat-el-api-7.0.37.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/el/Expression.class
2013-03-09 04:35:05 org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/home/apm/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/keepGeo/WEB-INF/lib/tomcat-servlet-api-7.0.37.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
2013-03-09 04:35:05 org.apache.tomcat.util.digester.Digester endElement
SEVERE: End event threw exception
java.lang.NoSuchMethodException: org.apache.catalina.deploy.WebXml addServlet
2013-03-09 04:35:05 org.apache.catalina.startup.ContextConfig parseWebXml
SEVERE: Parse error in application web.xml file at file:/home/apm/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/conf/web.xml
org.xml.sax.SAXParseException; systemId: file:/home/apm/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/conf/web.xml; lineNumber: 103; columnNumber: 15; Error at (103, 15) : org.apache.catalina.deploy.WebXml addServlet
...

当我选择其他选项'war','pom'时,我得到:

...
2013-03-09 04:47:14 org.apache.catalina.startup.ContextConfig processAnnotationsJar
SEVERE: Unable to process Jar entry [org/springframework/orm/ibatis/SqlMapClientTemplate$10.class] from Jar [jar:file:/home/apm/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/keepGeo/WEB-INF/lib/spring-orm-3.2.1.RELEASE.jar!/] for annotations
java.util.zip.ZipException: invalid LOC header (bad signature)

我尝试 <scope>provided</scope>在 pom.xml 中添加 tomcat-el-api 和 tomcat-servlet-api 依赖项,但没有成功。我也多次尝试清理和构建 Maven/Project...不知道下一步该做什么。

[编辑]

pom.xml:

<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>keepGeo</groupId>
  <artifactId>keepGeo</artifactId>
  <version>0.0.1-SNAPSHOT</version>
   <repositories>
      <repository>
    <id>Geoserver-Manager</id>
    <url>http://maven.geo-solutions.it/</url>
      </repository>
    </repositories>
  <dependencies>

    <dependency>
      <groupId>org.eclipse.jdt.core.compiler</groupId>
      <artifactId>ecj</artifactId>
      <version>4.2.1</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-tribes</artifactId>
      <version>7.0.37</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-jdbc</artifactId>
      <version>7.0.37</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-jasper-el</artifactId>
      <version>7.0.37</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-util</artifactId>
      <version>7.0.37</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-jsp-api</artifactId>
      <version>7.0.37</version>
    </dependency>
    <dependency>
    <scope>provided</scope>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-el-api</artifactId>
      <version>7.0.37</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-i18n-fr</artifactId>
      <version>7.0.37</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-jasper</artifactId>
      <version>7.0.37</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-i18n-ja</artifactId>
      <version>7.0.37</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-catalina-ha</artifactId>
      <version>7.0.37</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-api</artifactId>
      <version>7.0.37</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-annotations-api</artifactId>
      <version>7.0.37</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-catalina-ant</artifactId>
      <version>7.0.37</version>
    </dependency>
    <dependency>
        <scope>provided</scope>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-catalina</artifactId>
      <version>7.0.37</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-dbcp</artifactId>
      <version>7.0.37</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-i18n-es</artifactId>
      <version>7.0.37</version>
    </dependency>
    <dependency>
    <scope>provided</scope>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-servlet-api</artifactId>
      <version>7.0.37</version>
    </dependency>
    <dependency>
      <groupId>org.apache.tomcat</groupId>
      <artifactId>tomcat-coyote</artifactId>
      <version>7.0.37</version>
    </dependency>
    <dependency>
      <groupId>antlr</groupId>
      <artifactId>antlr</artifactId>
      <version>2.7.7</version>
    </dependency>
    <dependency>
      <groupId>org.antlr</groupId>
      <artifactId>antlr-runtime</artifactId>
      <version>3.5</version>
    </dependency>
    <dependency>
      <groupId>commons-collections</groupId>
      <artifactId>commons-collections</artifactId>
      <version>3.2.1</version>
    </dependency>
    <dependency>
      <groupId>commons-dbcp</groupId>
      <artifactId>commons-dbcp</artifactId>
      <version>1.4</version>
    </dependency>
    <dependency>
      <groupId>commons-logging</groupId>
      <artifactId>commons-logging</artifactId>
      <version>1.1.1</version>
    </dependency>
    <dependency>
      <groupId>commons-pool</groupId>
      <artifactId>commons-pool</artifactId>
      <version>1.6</version>
    </dependency>
    <dependency>
      <groupId>dom4j</groupId>
      <artifactId>dom4j</artifactId>
      <version>1.6.1</version>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>ejb3-persistence</artifactId>
      <version>1.0.2.GA</version>
    </dependency>
    <dependency>
      <groupId>org.hibernate.common</groupId>
      <artifactId>hibernate-commons-annotations</artifactId>
      <version>4.0.1.Final</version>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-core</artifactId>
      <version>4.1.10.Final</version>
    </dependency>
    <dependency>
      <groupId>org.hibernate.javax.persistence</groupId>
      <artifactId>hibernate-jpa-2.0-api</artifactId>
      <version>1.0.1.Final</version>
    </dependency>
    <dependency>
      <groupId>org.javassist</groupId>
      <artifactId>javassist</artifactId>
      <version>3.15.0-GA</version>
    </dependency>
    <dependency>
      <groupId>org.jboss.logging</groupId>
      <artifactId>jboss-logging</artifactId>
      <version>3.1.0.GA</version>
    </dependency>
    <dependency>
      <groupId>org.jboss.spec.javax.transaction</groupId>
      <artifactId>jboss-transaction-api_1.1_spec</artifactId>
      <version>1.0.0.Final</version>
    </dependency>
    <dependency>
      <groupId>jstl</groupId>
      <artifactId>jstl</artifactId>
      <version>1.2</version>
    </dependency>
    <dependency>
      <groupId>javax.transaction</groupId>
      <artifactId>transaction-api</artifactId>
      <version>1.1</version>
    </dependency>
    <dependency>
      <groupId>org.jumpmind.symmetric.jdbc</groupId>
      <artifactId>postgresql</artifactId>
      <version>9.2-1002-jdbc4</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>1.7.2</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-simple</artifactId>
      <version>1.7.2</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-aop</artifactId>
      <version>3.2.1.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-beans</artifactId>
      <version>3.2.1.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
      <version>3.2.1.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context-support</artifactId>
      <version>3.2.1.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
      <version>3.2.1.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-expression</artifactId>
      <version>3.2.1.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-jdbc</artifactId>
      <version>3.2.1.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-config</artifactId>
      <version>3.1.3.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-core</artifactId>
      <version>3.1.3.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-taglibs</artifactId>
      <version>3.1.3.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.security</groupId>
      <artifactId>spring-security-web</artifactId>
      <version>3.1.3.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-tx</artifactId>
      <version>3.2.1.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-web</artifactId>
      <version>3.2.1.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-webmvc</artifactId>
      <version>3.2.1.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>taglibs</groupId>
      <artifactId>standard</artifactId>
      <version>1.1.2</version>
    </dependency>
    <dependency>
    <groupId>it.geosolutions</groupId>
    <artifactId>geoserver-manager</artifactId>
    <version>1.3.0</version>
  </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>3.2.1.RELEASE</version>
    </dependency>
  </dependencies>
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.0</version>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <packaging>war</packaging>
</project>
4

1 回答 1

0

你想发动一场战争。

对于容器提供的所有 maven 依赖项(servlet jar 等),您需要添加scope元素。

例如

<dependency>
    <groupId>org.apache.tomcat</groupId>
    <artifactId>tomcat-api</artifactId>
    <version>7.0.37</version>
    <scope>provided</scope>
</dependency>

这样你的类将被编译,但这些 jars 不会进入你的战争的最终构建。

于 2013-03-09T14:39:59.270 回答