同一聚合工程下不同module之间无法自动引入问题解决
2018-01-09 18:28
459 查看
项目关系如下 :
Taotao-parent:父工程,打包方式pom,管理jar包的版本号。
| 项目中所有工程都应该继承父工程。
|–Taotao-common:通用的工具类通用的pojo。打包方式jar
|–Taotao-manager:服务层工程。聚合工程。Pom工程
|–taotao-manager-dao:打包方式jar
|–taotao-manager-pojo:打包方式jar
|–taotao-manager-interface:打包方式jar
|–taotao-manager-service:打包方式:war
|–taotao-manager-web:表现层工程。打包方式war
本来应该是service的module依赖dao,dao依赖pojo,而它们的父工程manager依赖common,
但实际操作时发现,在同一聚合工程manager下,servcie中的类ItemServiceImpl如果要实现interface中的类ItemService,无法实现
报错如下:
Taotao-parent:父工程,打包方式pom,管理jar包的版本号。
| 项目中所有工程都应该继承父工程。
|–Taotao-common:通用的工具类通用的pojo。打包方式jar
|–Taotao-manager:服务层工程。聚合工程。Pom工程
|–taotao-manager-dao:打包方式jar
|–taotao-manager-pojo:打包方式jar
|–taotao-manager-interface:打包方式jar
|–taotao-manager-service:打包方式:war
|–taotao-manager-web:表现层工程。打包方式war
本来应该是service的module依赖dao,dao依赖pojo,而它们的父工程manager依赖common,
但实际操作时发现,在同一聚合工程manager下,servcie中的类ItemServiceImpl如果要实现interface中的类ItemService,无法实现
报错如下:
[INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building taotao-manager-service 0.0.1-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ taotao-manager-service --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 5 resources [INFO] [INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ taotao-manager-service --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) @ taotao-manager-service --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 0 resource [INFO] [INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) @ taotao-manager-service --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 1 source file to D:\class\taotao\taotao-manager\taotao-manager-service\target\test-classes [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ taotao-manager-service --- [INFO] Surefire report directory: D:\class\taotao\taotao-manager\taotao-manager-service\target\surefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running com.taotao.mybatis.pagehelper.TestPageHelper log4j:WARN No appenders could be found for logger (org.springframework.core.env.StandardEnvironment). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.285 sec <<< FAILURE! testPageHelper(com.taotao.mybatis.pagehelper.TestPageHelper) Time elapsed: 1.205 sec <<< ERROR! org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.taotao.service.impl.ItemServiceImpl]; nested exception is java.io.FileNotFoundException: class path resource [com/taotao/service/ItemService.class] cannot be opened because it does not exist at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:181) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:321) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:243) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:98) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:678) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:520) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139) at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83) at com.taotao.mybatis.pagehelper.TestPageHelper.testPageHelper(TestPageHelper.java:19) 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.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252) at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141) at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112) 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.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189) at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165) at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85) at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115) at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75) Caused by: java.io.FileNotFoundException: class path resource [com/taotao/service/ItemService.class] cannot be opened because it does not exist at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172) at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:50) at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:98) at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:102) at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:93) at org.springframework.context.annotation.ConfigurationClassParser.asSourceClass(ConfigurationClassParser.java:620) at org.springframework.context.annotation.ConfigurationClassParser$SourceClass.getInterfaces(ConfigurationClassParser.java:813) at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:297) at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:231) at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:198) at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:167) ... 38 more Results : Tests in error: testPageHelper(com.taotao.mybatis.pagehelper.TestPageHelper): Failed to parse configuration class [com.taotao.service.impl.ItemServiceImpl]; nested exception is java.io.FileNotFoundException: class path resource [com/taotao/service/ItemService.class] cannot be opened because it does not exist Tests run: 1, Failures: 0, Errors: 1, Skipped: 0 [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 7.809 s [INFO] Finished at: 2018-01-09T18:16:35+08:00 [INFO] Final Memory: 21M/198M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project taotao-manager-service: There are test failures. [ERROR] [ERROR] Please refer to D:\class\taotao\taotao-manager\taotao-manager-service\target\surefire-reports for the individual test results. [ERROR] -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException[/code]
主要信息仍是这条找不到interface中的ItemServcieorg.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.taotao.service.impl.ItemServiceImpl]; nested exception is java.io.FileNotFoundException: class path resource [com/taotao/service/ItemService.class] cannot be opened because it does not exist
于是我强行在service中又去依赖了interface,这样一来,是可以正常启动了,但是仍然无法让这个服务正常执行,
这个原因是我通过启动web工程时,注释掉dubbo服务发现的
相关文章推荐
- 无法打开ddraw.lib问题的解决 -- 将DirectX引入到VS工程中
- 解决无法引入外部Myeclipse工程问题
- java 聚合工程同级相互引入函数问题。interface无法引入与父类相同级别的common中的函数
- 解决Python工程依赖包无法自动安装的问题(Linux环境下)
- 解决“Linux无法登录,显示module is unknown”问题
- 在Ubuntu中用repo下载和同步不同的工程,提示不能下载的问题解决方法
- 解决Win10无法自动连接隐藏网络的问题
- XP下IvideoWindow窗口无法自动关闭问题的解决
- VMware Workstation中客户机与主机之间无法复制文件和剪切板问题解决
- 解决spring 自动扫描包的时候出现 service无法自动注入的问题
- 浏览器版本不同导致文件无法下载问题解决方法
- ssh 无法自动登录问题解决
- Gentoo - U盘无法自动挂载,打开报告Not Authorized,xfce只有logout,suspend/shutdown灰化等问题解决方法
- 如何解决不同格式的文件在Tomcat下无法下载问题
- 解决在IE8浏览器里,在同一个IE进程中的不同选项卡之间的sessionID共享问题
- 不同module依赖多个aar问题解决方案
- HTTP接口不同项目网页之间数据交互跨域以及打开的窗口无法跳出关掉的问题
- 如何解决Ubuntu 12.04(64位)系统在virtualbox环境下无法开机自动挂载共享目录的问题
- 解决Atom中文无法自动换行问题
- DEDECMS 自动缩略图无法生成问题的解决方法