Boot ͔֬ʹૣ͍ʂ ͕ɺ͔ͦ͜Β Spring ͷੈքɻࢼ͞ΕΔ Spring ྗɾɾɾʂ ʢࢁͷϥΠϒϥϦɺΈ߹ΘͤɺSpring ͷࣝʣ ͦ͜ͰɺຊηογϣϯͰɺ Spring Boot Λ༻͍ͨී௨ͷ Web ΞϓϦέʔγϣϯΛ࡞͢Δࡍʹɺ ࠷ॳʹΔ͖ΞϓϦέʔγϣϯج൫ͷߏஙΛ Spring ͰͲ͏͢Δͷ͔ʁ Λத৺ʹ͓͠͠·͢ɻ ΰʔϧ ʰػೳ։ൃ Readyʱͳঢ়ଶΛ࡞Δ͜ͱ
public class HelloController { @RequestMapping("/admin/hello") public String hello(@RequestParam("name") String name, Model model) { if (name.equals("yoshida")) { throw new AuthorizationException("AuthorizationException error."); } model.addAttribute("name", name); return "screen/admin/hello"; } } @ResponseStatus(HttpStatus.FORBIDDEN) ͷ͍ͭͨ ྫ֎Λ Throw ͢Δ name ͕ແ͍ͱ͖ Spring ͔Β MissingServletRequestParameterException ͕ Throw ͞ΕΔ
Boot ͰɺϓϩύςΟҎԼͷॱংͰಡΈࠐ·ΕΔʢ্ͷํ͕༏ઌʣ 1. Command line arguments. 2. Properties from SPRING_APPLICATION_JSON (inline JSON embedded in an environment variable or system property) 3. ServletConfig init parameters. 4. ServletContext init parameters. 5. JNDI attributes from java:comp/env. 6. Java System properties (System.getProperties()). 7. OS environment variables. 8. A RandomValuePropertySource that only has properties in random.*. 9. Profile-specific application properties outside of your packaged jar (application- {profile}.properties and YAML variants) 10.Profile-specific application properties packaged inside your jar (application- {profile}.properties and YAML variants) 11.Application properties outside of your packaged jar (application.properties and YAML variants). 12.Application properties packaged inside your jar (application.properties and YAML variants). 13.@PropertySource annotations on your @Configuration classes. 14.Default properties (specified using SpringApplication.setDefaultProperties).
spring.datasource.password="dummy" SPRING_DATASOURCE_PASSWORD="hogehoge" OS ڥม Spring Boot ͰɺRelaxed binding ͷػೳ͕͋ΔͷͰɺ্هͷมಉ͡ɻ Property Note person.firstName Standard camel case syntax. person.first-name Dashed notation, recommended for use in .properties and .yml files. PERSON_FIRST_NAME Upper case format. Recommended when using a system environment variables. http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot- features-external-config-relaxed-binding