我有一个基于注释的 spring-boot
应用程序,想要导入 src/main/webapp/WEB-INF/appContext.xml
。
以下方法不起作用:
@Configuration
@EnableAutoConfiguration
@ImportResource("classpath*:appContext.xml")
public class AppConfig {
}
但是如果我将 appContext.xml
复制到 src/main/resources
,它就会按预期工作。
如何使 WEB-INF
文件夹正常工作?
最佳答案
好的,根据 @geoand 发布的文档,我发现了以下内容:
Do not use the src/main/webapp folder if your application will be packaged as a jar. Although this folder is a common standard, it will only work with war packaging and it will be silently ignored by most build tools if you generate a jar.
很明显,我确实应该将上下文文件复制到 src/main/resources
。
关于java - 如何使用Spring-Boot导入appContext.xml?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25622906/