简体   繁体   中英

How to import spring configuration?

I have this project structure:

在此处输入图片说明

What I can to write in @ContextConfiguration(locations = { "what I must write here?" }) for success import?

@ContextConfiguration("file:src/main/webapp/WEB-INF/spring/spring_config.xml")

See Location of spring-context.xml

You can also move files to the resources folder:

you could store your Spring configuration files in the classpath (eg, src/main/resources) and then reference them via the classpath.

@ContextConfiguration("classpath:/WEB-INF/spring/spring_config.xml")

Firstly you will need to add webapp as a source folder, so that WEB-INF is available at the top of the classpath (as it will be in the deployed app). Then you can use /WEB-INF/spring/security_config.xml .

Alternatively, some people prefer to put their XML files in src/main/resources instead.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM