简体   繁体   English

将Hibernate导入Eclipse中的项目

[英]Import hibernate into a project in Eclipse

I work on a project already developped by someone else and I'm actually trying to run it. 我正在研究别人已经开发的项目,而我实际上正在尝试运行它。 This project is using Hibernate but all the import are creating an error in Eclipse. 该项目正在使用Hibernate,但是所有导入都在Eclipse中创建错误。 I found that the project needs a .xml file where hibernate is configured but I don't know if it's the problem. 我发现该项目需要在其中配置了hibernate的.xml文件,但我不知道这是否是问题。

This is the import in the project : 这是项目中的导入:

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

And this is the .xml file : 这是.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>

Help please ! 请帮助 !

EDIT : 编辑:

This is the parts where hibernate is : 这是休眠的部分:

<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>

You project seems to be not well imported, 您的项目似乎没有很好地导入,

can you import it again ? 您可以再次导入吗?

导入日食

after you select 选择之后

Maven项目

And you select your project 然后选择您的项目

If you can't add you project, maybe change all the pom.xml with this 如果您无法添加您的项目,则可以使用此命令更改所有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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM