将hibernate导入Eclipse中的项目

时间:2015-10-19 12:14:42

标签: java eclipse hibernate

我正在开发一个已由其他人开发的项目,我实际上正在尝试运行它。这个项目正在使用Hibernate,但所有导入都在Eclipse中创建了一个错误。我发现该项目需要一个.xml文件,其中配置了hibernate,但我不知道是不是问题。

这是项目中的导入:

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.CriteriaSpecification;

这是.xml文件:

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate     Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-    configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
    <property          name="connection.driver_class">com.mysql.jdbc.Driver</property>

    <property name="connection.datasource">java:persystDs</property>        
    <property name="dialect">org.hibernate.dialect.MySQLDialect</property>  
    <property name="current_session_context_class">thread</property>
    <property name="hibernate.cache.use_second_level_cache">false</property>
    <property name="hibernate.cache.use_query_cache">false</property>
    <property name="show_sql">false</property>  
    <property name="hbm2ddl.auto">update</property>

    <property name="hibernate.transaction.factory_class">org.hibernate.transaction.CMTTransactionFactory</property>


    <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>

</session-factory>

请帮忙!

编辑:

这是hibernate所在的部分:

<exclusion>
                <groupId>eu.akka.jbossas</groupId>
                <artifactId>hibernate-commons-annotations</artifactId>
            </exclusion>
            <exclusion>
                <groupId>eu.akka.jbossas</groupId>
                <artifactId>hibernate-core</artifactId>
            </exclusion>
<exclusion>
                <groupId>eu.akka.jbossas</groupId>
                <artifactId>hibernate-jpa-2.0-api</artifactId>
            </exclusion>
            <exclusion>
                <groupId>eu.akka.jbossas</groupId>
                <artifactId>hibernate-validator</artifactId>
            </exclusion>



<dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>3.3.1.GA</version>
        <exclusions>
            <exclusion>
                <artifactId>javassist</artifactId>
                <groupId>javassist</groupId>
            </exclusion>
        </exclusions>
    </dependency>



<dependency>
        <groupId>fr.inra.grignon</groupId>
        <artifactId>persyst-common</artifactId>
        <version>1.0-SNAPSHOT</version>
        <exclusions>
            <exclusion>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate</artifactId>
            </exclusion>
            <exclusion>
                <groupId>javax</groupId>
                <artifactId>javaee-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>

1 个答案:

答案 0 :(得分:1)

您的项目似乎没有很好地导入,

可以再次导入吗?

Import in eclipse

选择

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>fr.inra.grignon</groupId>
<artifactId>fr.inra.grignon.hibernate</artifactId>

<dependencies>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>3.3.1.GA</version>
        <exclusions>
            <exclusion>
                <artifactId>javassist</artifactId>
                <groupId>javassist</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>fr.inra.grignon</groupId>
        <artifactId>persyst-common</artifactId>
        <version>1.0-SNAPSHOT</version>
        <exclusions>
            <exclusion>
                <groupId>org.hibernate</groupId>
                <artifactId>hibernate</artifactId>
            </exclusion>
            <exclusion>
                <groupId>javax</groupId>
                <artifactId>javaee-api</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
</dependencies> 
</project>