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

天涯浪子 提交于 2019-11-28 21:44:11

问题: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  

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!