Spring boot learning

1. Spring boot builds the standard way

    It is generally recommended to put the main class of the application at the top level of the package where other classes are located (root package), and annotate @EnableAutoConfiguration on your main class, which implicitly defines a basic package search path (search package), to search for some specific annotated entities (such as @Service , @Component, etc.). For example, if you are writing a JPA application, Spring will search for @Entity entities under the package where the @EnableAutoConfiguration annotated class resides  . With the root package method, you can use the @ComponentScan annotation without specifying the basePackage attribute, or you can use the @SpringBootApplication annotation, just put the
main class in the root package.

Spring boot recommends using the annotation form to configure the file. If you must use the xml configuration file, you can use @ImportResource to import the xml file.

2. spring-boot-devtools hot loading

    To prevent devtools from being passed to other modules in the project, set this dependency level to optional.

3. YAML files cannot be loaded through the @PropertySource annotation. If you need to use this method, you
must use the properties file

4. If the convention-based mapping is not flexible enough, you can use ServletRegistrationBean, FilterRegistrationBean, ServletListenerRegistrationBean to achieve full control.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325155758&siteId=291194637