对于我的spring boot应用程序,我使用了基于注释的配置和WebApplicationInitalizer。
我的一个依赖项在包含在jar中的xml中提供了一个spring配置。我使用@ImportResource加载上下文xml。这似乎是可行的,只是在这个xml中有属性占位符,例如${poolsize:10}。
显然,spring不会自动替换这些占位符(我得到了一个NumberFormatException)。我需要添加一些额外的配置吗?
我们的启动类:
public class Application implements WebApplicationInitializer {
@Override
public void onStartup(ServletContext container) throws ServletException {
// Create the 'root' Spring application context
AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
// config
rootContext.register(JmsConfiguration.class);
// Manage the lifecycle of the root application context
container.addListener(new ContextLoaderListener(rootContext));
}
}和configuration类(我们使用spring-jms):
@Configuration
@EnableJms
@ComponentScan(basePackages = { "..." })
public class JmsConfiguration implements JmsListenerConfigurer {
// config for jms listener and jaxb, nothing to do with property handling
}也许我错误地认为使用WebapplicationInitializer就是使用spring boot。也许我们甚至不需要弹力靴?我们使用的唯一与spring boot相关的依赖关系是:
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>1.5.3.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>我们使用的Spring依赖:
org.springframework:spring-context:jar:4.3.8.RELEASE:compile
org.springframework:spring-jms:jar:4.3.8.RELEASE:compile
org.springframework:spring-oxm:jar:4.3.8.RELEASE:compile
org.springframework:spring-context:jar:4.3.8.RELEASE:compile
org.springframework:spring-beans:jar:4.3.8.RELEASE:compilehttps://stackoverflow.com/questions/44414138
复制相似问题