0

再次在这里(我不得不重写它以使其更全面):

我得到了项目 X 和项目 Y。它们彼此独立。虽然项目 X 正在处理所有休眠依赖项,但我在项目 Y 上获得了具有相同依赖项的 ClassNotFound Exceptions 和 NoClassDefFoundErrors。发生错误,因为休眠 jar 似乎没有部署在项目 Y 上。我必须将它们逐个 jar 放在它们为运行时部署的 WEB-INF/lib 文件夹中,而在项目 X 中它们已经通过依赖项部署. 区别:项目 Y 有一个父项目。

这里是 pom.xml :

工作项目 X:

    <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>org.hibernate.tutorials</groupId>
        <artifactId>hibernate-tutorial</artifactId>
        <packaging>jar</packaging>
        <version>1.0.0-SNAPSHOT</version>
        <name>First Hibernate Tutorial</name>


        <dependencies>
            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-core</artifactId>
                <version>4.1.3.Final</version>
            </dependency>

    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>servlet-api</artifactId>
        <version>6.0.35</version>
    </dependency>

            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-simple</artifactId>
                <version>1.6.4</version>
            </dependency>

            <dependency>
                <groupId>javassist</groupId>
                <artifactId>javassist</artifactId>
                <version>3.12.1.GA</version>
            </dependency>

        <dependency>
            <groupId>javax.transaction</groupId>
            <artifactId>jta</artifactId>
            <version>1.1</version>
        </dependency>

              <dependency>
                <groupId>org.hsqldb</groupId>
                <artifactId>hsqldb</artifactId>
                <version>2.0.0</version>
            </dependency>

        </dependencies>     
    </project>

项目 Y:

    <?xml version="1.0"?>
    <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <modelVersion>4.0.0</modelVersion>
      <parent>
        <artifactId>com-project</artifactId>
        <groupId>com.project</groupId>
        <version>1.0-SNAPSHOT</version>
      </parent>
      <groupId>com.project.core</groupId>
      <artifactId>com-project-core</artifactId>
      <version>1.0-SNAPSHOT</version>
      <packaging>war</packaging>
      <name>com-project-core Jersey Webapp</name>

      <dependencies>
        <dependency>
          <groupId>com.project.facade</groupId>
          <artifactId>com-project-facade</artifactId>
          <version>1.0-SNAPSHOT</version>
        </dependency>

        <dependency>
          <groupId>junit</groupId>
          <artifactId>junit</artifactId>
          <version>4.8.2</version>
          <scope>test</scope>
        </dependency>

                    <!-- Hibernate -->

            <dependency>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate-core</artifactId>
                <version>4.1.3.Final</version>
            </dependency>

            <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>servlet-api</artifactId>
        <version>6.0.35</version>
    </dependency>

            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-simple</artifactId>
                <version>1.6.4</version>
            </dependency>

            <dependency>
                <groupId>javassist</groupId>
                <artifactId>javassist</artifactId>
                <version>3.12.1.GA</version>
            </dependency>


      </dependencies>
    </project>

项目Y父pom:

    <?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>com.project</groupId>
      <artifactId>com-project</artifactId>
      <version>1.0-SNAPSHOT</version>
      <packaging>pom</packaging>

      <name>com-project</name>
      <url>http://maven.apache.org</url>

      <modules>
        <module>com-project-core</module>
        <module>com-project-client</module>
        <module>com-project-facade</module>
      </modules>

      <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      </properties>


    </project>

我已经尝试过这种尝试,但一切就绪。

4

0 回答 0