Spring +无法加载Hibernate注释jar

时间:2014-10-08 12:00:01

标签: hibernate maven spring-mvc

我遇到了错误。

java.lang.ClassNotFoundException: org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean

这是Pom.xml。如果我遗漏任何Jar或jar版本文件之间的任何冲突,请告诉我。

<?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>MySpringMvc</groupId>
    <artifactId>MySpringMvc</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>MySpringMvc</name>
    <url>http://maven.apache.org</url>

    <properties>
        <java.version>1.6</java.version>
        <spring.version>3.1.0.RELEASE</spring.version>
        <cglib.version>2.2.2</cglib.version>
        <hibernate.version>3.6.9.Final</hibernate.version>
    </properties>

    <dependencies>
        <!-- Spring core & mvc -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-orm</artifactId>
            <version>${spring.version}</version>
            <type>jar</type>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${spring.version}</version>
            <type>jar</type>
            <scope>test</scope>
        </dependency>

        <!-- CGLib for @Configuration -->
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib-nodep</artifactId>
            <version>${cglib.version}</version>
            <scope>runtime</scope>
        </dependency>


        <!-- Servlet Spec -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
              <groupId>org.springframework</groupId>
              <artifactId>spring-jdbc</artifactId>
              <version>${spring.version}</version>
        </dependency>
        <!-- Hibernate --> 
        <dependency> 
            <groupId>org.hibernate</groupId> 
            <artifactId>hibernate-entitymanager</artifactId> 
            <version>${hibernate.version}</version> 
        </dependency> 
        <dependency> 
            <groupId>org.hibernate</groupId> 
            <artifactId>hibernate-core</artifactId> 
            <version>${hibernate.version}</version> 
        </dependency> 

        <dependency> 
            <groupId>mysql</groupId> 
            <artifactId>mysql-connector-java</artifactId> 
            <version>5.1.28</version> 
        </dependency> 
        <dependency> 
            <groupId>commons-dbcp</groupId> 
            <artifactId>commons-dbcp</artifactId> 
            <version>1.4</version> 
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
             <artifactId>spring-tx</artifactId>
            <version>${spring.version}</version>
         </dependency>


    </dependencies>

    <repositories>
        <repository>
            <id>springsource-milestones</id>
            <name>SpringSource Milestones Proxy</name>
            <url>https://oss.sonatype.org/content/repositories/springsource-milestones</url>
        </repository>
    </repositories>

    <build>
        <finalName>MySpringMvc</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.0.2</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

感谢

1 个答案:

答案 0 :(得分:0)

请在构建路径中添加spring-orm-3.1.1.RELEASE.jar。

here

下载