码迷,mamicode.com
首页 > 编程语言 > 详细

eclipse&myeclipse 生成jar包后,spring无法扫描到bean定义

时间:2019-08-29 09:47:00      阅读:88      评论:0      收藏:0      [点我收藏+]

标签:city   mic   class   direct   cli   ring   info   director   code   

问题:eclipse&myeclipse 生成jar包后,spring无法扫描到bean定义

在使用getbean或者扫包时注入bean失败,但在IDE里是可以正常运行的?

原因:导出jar未将目录一起导出。

解决方法:将代码目录一起导出:一定要勾选 Add directory enttries

技术图片

 

区别:

代码结构:

技术图片

未勾选,导出内容为:

META-INF/MANIFEST.MF  
com/wang/util/DateStyle.class  
com/wang/util/PropertiesUtil$1.class  
com/wang/util/PropertiesUtil.class  
com/wang/util/Week.class  
com/wang/util/DateUtil.class  
com/wang/vo/request/hotel/test/PopularCityRequest.class  
com/wang/vo/request/hotel/test/EconomicsRequest.class  
com/wang/vo/request/hotel/test/HotelProductVouchRequest.class  
com/wang/vo/request/hotel/test/QueryOrderListRequest.class  
com/wang/vo/request/hotel/test/HotelListQueryRequest.class  
com/wang/vo/request/hotel/test/RoomReserveRequest.class  
com/wang/vo/request/hotel/test/HotelOneQueryRequest.class  
com/wang/vo/request/hotel/test/HotelBrandRequest.class

勾选,导出内容为:

META-INF/MANIFEST.MF  
com/  
com/wang/  
com/wang/util/  
com/wang/util/DateStyle.class  
com/wang/util/PropertiesUtil$1.class  
com/wang/util/PropertiesUtil.class  
com/wang/util/Week.class  
com/wang/util/DateUtil.class  
com/wang/vo/  
com/wang/vo/request/  
com/wang/vo/request/hotel/  
com/wang/vo/request/hotel/test/  
com/wang/vo/request/hotel/test/PopularCityRequest.class  
com/wang/vo/request/hotel/test/EconomicsRequest.class  
com/wang/vo/request/hotel/test/HotelProductVouchRequest.class  
com/wang/vo/request/hotel/test/QueryOrderListRequest.class  
com/wang/vo/request/hotel/test/HotelListQueryRequest.class  
com/wang/vo/request/hotel/test/RoomReserveRequest.class  
com/wang/vo/request/hotel/test/HotelOneQueryRequest.class  
com/wang/vo/request/hotel/test/HotelBrandRequest.class  

 

eclipse&myeclipse 生成jar包后,spring无法扫描到bean定义

标签:city   mic   class   direct   cli   ring   info   director   code   

原文地址:https://www.cnblogs.com/cac2020/p/11427662.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!