从依赖罐类自动装配注解 [英] Auto-wiring annotations in classes from dependent jars
问题描述
我是比较新的Java,所以我希望这不是一个愚蠢的问题。
I'm relatively new to Java, so I hope this isn't a dumb question.
我在Eclipse Web项目,我试图部署到Tomcat。我有被编译成.jar文件,并部署到/ WEB-INF / lib目录在Eclipse两个因项目。
I have a Web project in Eclipse that I'm trying to deploy to Tomcat. I have two dependent projects in Eclipse which are being compiled into .jar files and deployed to the /WEB-INF/lib directory.
这是好的,但不幸的是,除非春季从.jar文件的类文件解压缩到/ WEB-INF / classes目录中不依赖扫描注释。
This is fine, but unfortunately Spring doesn't scan for annotations in dependencies unless the class files from the .jars are extracted into the /WEB-INF/classes directory.
有没有一种简单的方法来做到这一点的提取在制作的时候?我使用Maven。我写了暂时做到这一点(我开发在Windows上,部署在Ubuntu)
Is there an easy way to do this extraction at build time? I'm using Maven. I've written a batch file for the time being to do this (I'm developing on Windows, deploying on Ubuntu)
我有关于如何自动运行该服务器部署的问题,不过,我是不是做错了什么?当然,我不是这个问题搏斗唯一的一个。
I do have questions about how to automate this for server deployment, though, am I doing something wrong? Surely I'm not the only one to wrestle with this problem.
推荐答案
根据这个春天问题,
如果你在Eclipse中使用导出生成JAR文件...>的Java> JAR文件向导,然后你必须检查在添加目录条目复选框(默认情况下选中)为Spring的组件扫描来查找JAR文件的组件。
According to this Spring issue, if you're creating JAR files in Eclipse using the Export... > Java > JAR file wizard, then you have to check the Add directory entries checkbox (unchecked by default) for Spring's component scan to find components in the JAR files.
这篇关于从依赖罐类自动装配注解的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!