简体   繁体   English

org.hibernate.MappingNotFoundException:资源:找不到com / ypd / a / entity / Employee.hbm.xml

[英]org.hibernate.MappingNotFoundException: resource: com/ypd/a/entity/Employee.hbm.xml not found

I got a issue when I test the method: 我在测试方法时遇到问题:

org.junit.platform.launcher.core.ServiceLoaderTestEngineRegistry loadTestEngines 信息: Discovered TestEngines with IDs: [junit-jupiter, junit-vintage] log4j:WARN No appenders could be found for logger (org.hibernate.type.BasicTypeRegistry). org.junit.platform.launcher.core.ServiceLoaderTestEngineRegistry loadTestEngines信息:已发现ID的TestEngine:[junit-jupiter,junit-vintage] log4j:WARN找不到记录器的附加程序(org.hibernate.type.BasicTypeRegistry)。 log4j:WARN Please initialize the log4j system properly. log4j:WARN请正确初始化log4j系统。

org.hibernate.MappingNotFoundException: resource: com/ypd/a/entity/Employee.hbm.xml not found org.hibernate.MappingNotFoundException:资源:找不到com / ypd / a / entity / Employee.hbm.xml

at org.hibernate.cfg.Configuration.addResource(Configuration.java:769) at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:2314) at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:2280) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2260) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2213) at org.hibernate.cfg.Configuration.configure(Configuration.java:2128) at org.hibernate.cfg.Configuration.configure(Configuration.java:2107) at com.ypd.a.entity.App.testHello(App.java:24) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:289) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke( 在org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:2280)的org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:2314)处的org.hibernate.cfg.Configuration.addResource(Configuration.java:769) )的org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2260)的org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2213)的org.hibernate.cfg.Configuration.configure(Configuration.java: 2128)在org.hibernate.cfg.Configuration.configure(Configuration.java:2107)在com.ypd.a.entity.App.testHello(App.java:24)在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)在组织上的sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)在java.lang.reflect.Method.invoke(Method.java:498)在组织。 org.junit.jupiter.engine.execution.ExecutableInvoker.invoke上的junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:289) ExecutableInvoker.java:114) at org.junit.jupiter.engine.descriptor.MethodTestDescriptor.lambda$invokeTestMethod$7(MethodTestDescriptor.java:212) at org.junit.jupiter.engine.execution.ThrowableCollector.execute(ThrowableCollector.java:40) at org.junit.jupiter.engine.descriptor.MethodTestDescriptor.invokeTestMethod(MethodTestDescriptor.java:208) at org.junit.jupiter.engine.descriptor.MethodTestDescriptor.execute(MethodTestDescriptor.java:155) at org.junit.jupiter.engine.descriptor.MethodTestDescriptor.execute(MethodTestDescriptor.java:63) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.lambda$execute$0(HierarchicalTestExecutor.java:80) at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:76) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.lambda$execute$0(Hierarchica org.junit.jupiter.engine.descriptor.MethodTestDescriptor.lambda $ invokeTestMethod $ 7(MethodTestDescriptor.java:212)处的org.junit.jupiter.engine.execution.ThrowableCollector.execute(ThrowableCollector.java:40)的ExecutableInvoker.java:114) )在org.junit.jupiter的org.junit.jupiter.engine.descriptor.MethodTestDescriptor.execute(MethodTestDescriptor.java:155)的org.junit.jupiter.engine.descriptor.MethodTestDescriptor.invokeTestMethod(MethodTestDescriptor.java:208)处。 org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.lambda $ execute $ 0(HierarchicalTestExecutor.java:80)处的engine.descriptor.MethodTestDescriptor.execute(MethodTestDescriptor.java:63)在org.junit.platform.engine.support org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:76)上的.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66),位于org.junit.platform.engine.support.hierarchical.Hier .lambda $ execute $ 0(Hierarchica lTestExecutor.java:87) at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:76) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.lambda$execute$0(HierarchicalTestExecutor.java:87) at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:76) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:51) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:43) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:129) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.jav 在org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)处的org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java: 76)at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)上的org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.lambda $ execute $ 0(HierarchicalTestExecutor.java:87) ),位于组织org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:51)的org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:76)上。位于org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:129)的junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:43)在org.junit.platform.launcher处。 core.DefaultLauncher.execute(DefaultLauncher.jav a:85) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:59) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) a:85)位于com.intellij.rt.execution.junit.IdeaTestRunner $ Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)com.intellij.rt.execution.junit.IdeaTestRunner $ Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:59) com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)上的.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)

It state the org.hibernate.MappingNotFoundException: resource: com/ypd/a/entity/Employee.hbm.xml not found 它声明org.hibernate.MappingNotFoundException:资源:找不到com / ypd / a / entity / Employee.hbm.xml

But in the project directory: 但是在项目目录中:

And in the Employee.hbm.xml : 并在Employee.hbm.xml

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">



<hibernate-mapping package="com.ypd.a.entity">
    <class name="Employee" table="t_employee">

        <id name="empId" column="id">
            <generator class="native"/>
        </id>

        <property name="empName" column="emp_name"></property>
        <property name="workDate" column="workDate"></property>

    </class>
</hibernate-mapping>

Where is the issue? 问题出在哪里?

您的配置文件应放在资源目录中,java目录仅存储.java文件。

暂无
暂无

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

相关问题 org.hibernate.MappingNotFoundException:resource:*找不到hbm.xml - org.hibernate.MappingNotFoundException: resource: *hbm.xml not found org.hibernate.MappingNotFoundException:资源:找不到com / corp / dept / proj / FooTbl.hbm.xml - org.hibernate.MappingNotFoundException: resource: com/corp/dept/proj/FooTbl.hbm.xml not found 错误org.hibernate.MappingNotFoundException:资源:找不到name.hbm.xml - Error org.hibernate.MappingNotFoundException: resource: name.hbm.xml not found 休眠给我-“主要” org.hibernate.MappingNotFoundException:资源:找不到hibernate_hbm.xml.UserDetails.hbm.xml - hibernate is giving me - “main” org.hibernate.MappingNotFoundException: resource: hibernate_hbm.xml.UserDetails.hbm.xml not found org.hibernate.MappingNotFoundException:资源:找不到hibernate.cfg.xml - org.hibernate.MappingNotFoundException: resource: hibernate.cfg.xml not found Hibernate 无法从资源读取映射:Employee.hbm.xml - Hibernate Could not read mappings from resource: Employee.hbm.xml org.hibernate.MappingNotFoundException - org.hibernate.MappingNotFoundException 无法创建sessionFactory object.org.hibernate.InvalidMappingException:无法从资源Employee.hbm.xml中解析映射文档 - Failed to create sessionFactory object.org.hibernate.InvalidMappingException: Could not parse mapping document from resource Employee.hbm.xml 休眠:org.hibernate.MappingNotFoundException - Hibernate: org.hibernate.MappingNotFoundException 线程“main” org.hibernate.boot.MappingNotFoundException 中的异常:未找到映射(资源):allinone.hbm.xml:起源(allinone.hbm.xml) - Exception in thread "main" org.hibernate.boot.MappingNotFoundException: Mapping (RESOURCE) not found : allinone.hbm.xml : origin(allinone.hbm.xml)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM