gpt4 book ai didi

Java、maven、hibernate - 映射问题

转载 作者:太空宇宙 更新时间:2023-11-04 13:57:34 24 4
gpt4 key购买 nike

我尝试了一个多小时来查找错误,但仍然找不到:

     cd C:\Users\zimnyk\Documents\NetBeansProjects\kwestionariusz; "JAVA_HOME=C:\\Program Files\\Java\\jdk1.8.0_40" cmd /c "\"\"C:\\Program Files\\NetBeans 8.0.2\\java\\maven\\bin\\mvn.bat\" -Dexec.args=\"-classpath %classpath com.mycompany.kwestionariusz.main\" -Dexec.executable=\"C:\\Program Files\\Java\\jdk1.8.0_40\\bin\\java.exe\" -Dmaven.ext.class.path=\"C:\\Program Files\\NetBeans 8.0.2\\java\\maven-nblib\\netbeans-eventspy.jar\" -Dfile.encoding=UTF-8 org.codehaus.mojo:exec-maven-plugin:1.2.1:exec\""
Running NetBeans Compile On Save execution. Phase execution is skipped and output directories of dependency projects (with Compile on Save turned on) will be used instead of their jar artifacts.
Scanning for projects...

------------------------------------------------------------------------
Building kwestionariusz 1.0-SNAPSHOT
------------------------------------------------------------------------

--- exec-maven-plugin:1.2.1:exec (default-cli) @ kwestionariusz ---
kwi 16, 2015 11:29:46 AM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
kwi 16, 2015 11:29:46 AM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.3.1.Final}
kwi 16, 2015 11:29:46 AM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
16, 2015 11:29:46 AM org.hibernate.cfg.Environment buildBytecodeProvider

INFO: HHH000021: Bytecode provider name : javassist
kwi 16, 2015 11:29:46 AM org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
kwi 16, 2015 11:29:46 AM org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
kwi 16, 2015 11:29:46 AM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
kwi 16, 2015 11:29:46 AM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: Osoba.hbm.xml
kwi 16, 2015 11:29:46 AM org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
Initial SessionFactory creation failed.org.hibernate.InvalidMappingException: Unable to read XML
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.mycompany.kwestionariusz.util.NewHibernateUtil.<clinit>(NewHibernateUtil.java:31)
at com.mycompany.kwestionariusz.main.main(main.java:20)
Caused by: org.hibernate.InvalidMappingException: Unable to read XML
at org.hibernate.internal.util.xml.MappingReader.legacyReadMappingDocument(MappingReader.java:375)
at org.hibernate.internal.util.xml.MappingReader.readMappingDocument(MappingReader.java:304)
at org.hibernate.cfg.Configuration.add(Configuration.java:516)
at org.hibernate.cfg.Configuration.add(Configuration.java:512)
at org.hibernate.cfg.Configuration.add(Configuration.java:686)
at org.hibernate.cfg.Configuration.addResource(Configuration.java:769)
at org.hibernate.cfg.AnnotationConfiguration.addResource(AnnotationConfiguration.java:123)
at org.hibernate.cfg.AnnotationConfiguration.addResource(AnnotationConfiguration.java:46)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:2255)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:2227)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2207)
at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:213)
at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:46)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2160)
at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:201)
at org.hibernate.cfg.AnnotationConfiguration.doConfigure(AnnotationConfiguration.java:46)
at org.hibernate.cfg.Configuration.configure(Configuration.java:2075)
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:183)
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:46)
at org.hibernate.cfg.Configuration.configure(Configuration.java:2054)
at org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:177)
at com.mycompany.kwestionariusz.util.NewHibernateUtil.<clinit>(NewHibernateUtil.java:27)
... 1 more
Caused by: org.dom4j.DocumentException: Error on line 13 of document : The value of attribute "column" associated with an element type "null" must not contain the '<' character. Nested exception: The value of attribute "column" associated with an element type "null" must not contain the '<' character.
at org.dom4j.io.SAXReader.read(SAXReader.java:482)
at org.hibernate.internal.util.xml.MappingReader.legacyReadMappingDocument(MappingReader.java:325)
... 22 more
------------------------------------------------------------------------
BUILD FAILURE
------------------------------------------------------------------------
Total time: 2.478s
Finished at: Thu Apr 16 11:29:47 CEST 2015
Final Memory: 8M/106M
------------------------------------------------------------------------
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project kwestionariusz: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException]

这就是错误的样子,我的映射文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.mycompany.kwestionariusz.Osoba" table="DaneOsobowe">
<property name="imie" column="Imie"/>
<property name="nazwisko" column="Nazwisko"/>
<property name="telefon" column="Telefon"/>
<property name="email" column="Email"/>
<property name="uczelnia" column="Uczelnia"/>
<property name="doswiadczenie" column="Doswiadczenie"/>
<property name="zainteresowania" column="Zainteresowania"/>
<property name="skadSlyszal" column="SkadSlyszal"/>
</class>
</hibernate-mapping>

这是我的配置文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/postgres</property>
<property name="hibernate.connection.username">postgres</property>
<property name="hibernate.connection.password">test</property>
<mapping resource="Osoba.hbm.xml"/>


</session-factory>
</hibernate-configuration>

这是我第一次使用 maven 和 hibernate,所以这个错误对我来说看起来很糟糕,你能帮我吗?

主文件第20行是:

Session session = NewHibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();

NewJavaUtil 的第 ~31 行是:

}
catch (Throwable ex) {
// Log the exception.
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError(ex);
}

最佳答案

问题出在新行中,当我在映射文件中的所有内容之间添加新行时,它就开始工作

关于Java、maven、hibernate - 映射问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29670881/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com