Spring Boot入门

来源:互联网 发布:网络版权保护 编辑:程序博客网 时间:2024/06/05 05:43

Spring Boot入门

SpringBootApplication的用法

@Configuration tags the class as a source of bean definitions for the application context.
@EnableAutoConfiguration tells Spring Boot to start adding beans based on classpath settings, other beans, and various property settings.
Normally you would add @EnableWebMvc for a Spring MVC app, but Spring Boot adds it automatically when it sees spring-webmvc on the classpath. This flags the application as a web application and activates key behaviors such as setting up a DispatcherServlet.
@ComponentScan tells Spring to look for other components, configurations, and services in the hello package, allowing it to find the controllers.

如何运行Spring Boot的程序

1、直接使用maven运行程序:mvnw spring-boot:run
2、使用maven进行打包:mvnw clean package。再运行jar文件:java -jar target/gs-securing-web-0.1.0.jar


原创粉丝点击