当前位置: 首页 > 知识库问答 >
问题:

java.io.FileNotFoundException:无法打开类路径资源[../ProductDao.class],因为它不存在

汪志业
2023-03-14

我的项目结构是下面的屏幕截图。实际上,我得到了一个文件找不到的错误,尽管文件是存在的,我将添加错误在下面。我是Intellej的新手,这是我的第一个项目,我试图通过使用MySQL连接到数据库来制作一个音乐商店。下面是我的applicaiton-context.xml,dispatcher和web.xml是正确的。

我的日志文件是

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)

由:java.io.fileNotFoundException引起:无法打开类路径资源[com/emusicstore/dao/productdao.class],因为它不存在于getMetadataReaderFactory.getMetadataReaderFactory.java:102)在org.springframework.core.type.classreading.simpleMetadataReaderFactory.getMetadataReaderFactory.getMetadataReaderFactory(simpleMetadataReaderFactory.java:93),在org.springframework.context.annotation.configurationClassParser.assourceClass(configurationClassParser.java:621),在nnotation.configurationClassParser.doProcessConfigurationClass(configurationClassParser.java:298)在org.springframework.context.annotation.comfigurationClassParser.processConfigurationClass(configurationClassParser.java:232)在org.springframework.context.annotation.comfigurationClassParser.java:199)在org.springframework.context.annotation.comfigurationClassParser.parse(

2016年3月18日10:37:15.310严重[http-nio-8080-exec-1]org.apache.catalina.core.standardWrapperValve.invoke servlet dispatcher分配异常java.io.fileNotFoundException:无法打开类路径资源[com/emusicstore/dao/productDao.class],因为它不存在于org.springframework.core.io.classpathResource.getInputStream(ClasspathResource.java:172)和在org.springframework.core.type.classreading.cachingmetadatareaderfactory.getMetadatareaderfactory.getMetadatareaderfactory(cachingMetadatareaderfactory.java:98)在org.springframework.core.type.classreading.getMetadatareaderfactory.java:102),在或k.context.annotation.comfigurationClassParser$sourceClass.GetInterfaces(configurationClassParser.java:797)在org.springframework.context.annotation.comfigurationClassParser.doProcessConfigurationClass(configurationClassParser.java:298)在org.springframework.context.annotation.comfigurationClassParser.processConfigurationClass(configurationClassParser.java:232)在在org.springframework.context.annotation.configurationClassPostProcessor.PostProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:321)在org.springframework.context.support.PostProcessorRegistrationDefinitionRegistry(ConfigurationClassPostProcessor.java:243)在EssorRegistrationDelegate.java:273)在org.springframework.context.support.postprocessorRegistrationDelegrate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:98)在org.springframework.context.support.abstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:678)在.createWebApplicationContext(frameworkServlet.java:633)在org.springframework.web.servlet.frameworkServlet.createWebApplicationContext(frameworkServlet.java:681)在org.springframework.web.servlet.frameworkServlet.initWebApplicationContext(frameworkServlet.java:552)在org.springframework.web.servlet.httpServletbean.init(httpservletbean.java:136)在javax.servlet.genericservlet.init(GenericServlet.java:158)在org.apache.catalina.core.standardWrapper.init(StandardWrapper.java:1238)在org.apache.catalina.core.standardWrapper.initServlet(StandardWrapper.java:1151)在org.apache.catalina.core.standardWrapper.loadServlet(StandardWrapper.java:1151)在org.apache.catalina.authenticator.authenticator.authenticator.authenticatorbase.invoke(authenticatorbase.invoke(authenticatorbase.java:106)在org.apache.catalina.core.standardhostvalve.invoke(authenticatorbase.java:502)在org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:141)在java:88)在org.apache.catalina.connector.coyoteAdapteR.Service(coyoteAdapter.java:522)在org.apache.coyote.http11.abstractHttp11Processor.processor(AbstractHttp11Processor.java:1095)在org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.Process(AbstractProtocol.java:672)在org.apache.tomcat.util.net.nioEndpoint$socketProcessor.dorun:1142)在java.util.concurrent.ThreadPoolExecutor$worker.run(threadPoolExecutor.java:617)在org.apache.tomcat.util.threads.taskThread$wrappingrunnable.run(taskThread.java:61)在java.lang.thread.run(thread.java:745)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:616)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:522)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1095)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:672)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)

由:java.io.fileNotFoundException引起:无法打开类路径资源[com/emusicstore/dao/productdao.class],因为它不存在于getMetadataReaderFactory.getMetadataReaderFactory.java:102)在org.springframework.core.type.classreading.simpleMetadataReaderFactory.getMetadataReaderFactory.getMetadataReaderFactory(simpleMetadataReaderFactory.java:93),在org.springframework.context.annotation.configurationClassParser.assourceClass(configurationClassParser.java:621),在nnotation.configurationClassParser.doProcessConfigurationClass(configurationClassParser.java:298)在org.springframework.context.annotation.comfigurationClassParser.processConfigurationClass(configurationClassParser.java:232)在org.springframework.context.annotation.comfigurationClassParser.java:199)在org.springframework.context.annotation.comfigurationClassParser.parse(

2016年3月18日10:37:16.340严重[http-nio-8080-exec-3]org.apache.catalina.core.standardWrapperValve.invoke servlet dispatcher分配异常java.io.fileNotFoundException:无法打开类路径资源[com/emusicstore/dao/productDao.class],因为它不存在于org.springframework.core.io.classpathResource.getInputStream(ClasspathResource.java:172)和在org.springframework.core.type.classreading.cachingmetadatareaderfactory.getMetadatareaderfactory.getMetadatareaderfactory(cachingMetadatareaderfactory.java:98)在org.springframework.core.type.classreading.getMetadatareaderfactory.java:102),在或k.context.annotation.comfigurationClassParser$sourceClass.GetInterfaces(configurationClassParser.java:797)在org.springframework.context.annotation.comfigurationClassParser.doProcessConfigurationClass(configurationClassParser.java:298)在org.springframework.context.annotation.comfigurationClassParser.processConfigurationClass(configurationClassParser.java:232)在在org.springframework.context.annotation.configurationClassPostProcessor.PostProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:321)在org.springframework.context.support.PostProcessorRegistrationDefinitionRegistry(ConfigurationClassPostProcessor.java:243)在EssorRegistrationDelegate.java:273)在org.springframework.context.support.postprocessorRegistrationDelegrate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:98)在org.springframework.context.support.abstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:678)在.createWebApplicationContext(frameworkServlet.java:633)在org.springframework.web.servlet.frameworkServlet.createWebApplicationContext(frameworkServlet.java:681)在org.springframework.web.servlet.frameworkServlet.initWebApplicationContext(frameworkServlet.java:552)在org.springframework.web.servlet.httpServletbean.init(httpservletbean.java:136)在javax.servlet.genericservlet.init(GenericServlet.java:158)在org.apache.catalina.core.standardWrapper.init(StandardWrapper.java:1238)在org.apache.catalina.core.standardWrapper.initServlet(StandardWrapper.java:1151)在org.apache.catalina.core.standardWrapper.loadServlet(StandardWrapper.java:1151)在org.apache.catalina.authenticator.authenticator.authenticator.authenticatorbase.invoke(authenticatorbase.invoke(authenticatorbase.java:106)在org.apache.catalina.core.standardhostvalve.invoke(authenticatorbase.java:502)在org.apache.catalina.core.standardhostvalve.invoke(standardhostvalve.java:141)在java:88)在org.apache.catalina.connector.coyoteAdapteR.Service(coyoteAdapter.java:522)在org.apache.coyote.http11.abstractHttp11Processor.processor(AbstractHttp11Processor.java:1095)在org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.Process(AbstractProtocol.java:672)在org.apache.tomcat.util.net.nioEndpoint$socketProcessor.dorun:1142)在java.util.concurrent.ThreadPoolExecutor$worker.run(threadPoolExecutor.java:617)在org.apache.tomcat.util.threads.taskThread$wrappingrunnable.run(taskThread.java:61)在java.lang.thread.run(thread.java:745)

共有1个答案

滕英奕
2023-03-14

检查目标文件夹,看看ProductDao.class是否存在,如果不存在,它没有编译它,我想您使用的是Intellij,有时在Intellij中,目标文件夹自动被排除,右键单击目标文件夹并选择取消排除。还要确保类存在于dao包下,并且类的名称相同。另外,请检查bean是否配置正确。

我看到您的目标文件夹被排除在外,因为它是红色的,所以尝试取消排除,如果没有,请显示ProductDao是如何配置为bean的。

 类似资料: