自动连接从依赖罐的类中的注释 [英] Auto-wiring annotations in classes from dependent jars
问题描述
我在Eclipse中有一个Web项目,我试图部署到Tomcat。我在Eclipse中有两个依赖项目,它们被编译成.jar文件并被部署到/ WEB-INF / lib目录。
这很好,但不幸的是Spring不除非来自.jars的类文件被提取到/ WEB-INF / classes目录中,否则不会扫描依赖关系的注释。
有没有办法做到这一点在构建时提取?我正在使用Maven。我暂时写了一个批处理文件(我在Windows上开发,在Ubuntu上部署)
我对如何自动化这个问题有疑问对于服务器部署,但是我做错了什么?
根据这个 Spring问题,
如果您使用导出...> Java在Eclipse中创建JAR文件> JAR文件向导,那么您必须检查Spring组件扫描的添加目录条目复选框(未选中),以查找JAR文件中的组件。
I'm relatively new to Java, so I hope this isn't a dumb question.
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.
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.
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.
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屋!