The one that is set as below in web.xml.
web.xml
<context-param>
<param-name>p-name</param-name>
<param-value>-value</param-value>
</context-param>
Describe as follows in the property file.
application.yaml
server:
context_parameters:
p-name: hogehoge
p-name2: foobar
The following is the code for checking the operation.
@RestController
@SpringBootApplication
public class App {
@Autowired
ServletContext ctx;
@RequestMapping("/home")
public String hoge() {
System.out.println(ctx.getInitParameter("p-name"));
System.out.println(ctx.getInitParameter("p-name2"));
return "hoge";
}
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
However, according to How to set context-param in spring-boot, spring-boot 1.2 or later It's a function.
By the way, nothing happened when I put spring.profiles.active
here. At least in the boot log it will be `No active profile set ...`
.
application.yaml
server:
context_parameters:
spring.profiles.active: profile_ctx
Recommended Posts