I'm porting a Spring application to Spring Boot. I'd like to be able to configure Spring Security using xml so I can use my old config files. (I've tried using Java config and it doesn't work).
How do I get Spring Boot to pick up the xml configuration? Spring does not see to have any documentation on this.
You can import xml configuration using org.springframework.context.annotation.ImportResource
annotation. in one of the configuration class which is annotated with @Configuration
do the following.
If your security config is named security-config.xml
at the root of the classpath then add the like below.
@ImportResource({"classpath:security-config.xml"})
You have to use @ImportResource
.
@SpringBootApplication
@ImportResource("classpath:<name>.xml")
public class Config {
public static void main(String[] args) {
SpringApplication.run(Config.class, args);
}
}
Refer to these links for proper understanding :
Why do you want to import your old xml file ? The best thing about spring-boot is that you don't need to use your old file and you can rewrite it in java
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.