Spring Boot 微框架

Spring Boot是快速创建基于Spring的应用程序和服务的微框架,嵌入式服务器、安全、指标,健康检测、外部配置等功能。基于Spring Boot构建Spring Cloud构建微服务也是业界当下流行的技术架构

spring boot入口类Application—基于springmvc+tomcat切到springboot实战二

2017-08-23| 发布: | 浏览: 207 |保存PDF

spring boot入口类Application

package h.y.n.app;
  
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.web.WebApplicationInitializer;
  
@SpringBootApplication
@ComponentScan(value = {"h.y.n.config","h.y.n.**.service","h.y.n.support","h.y.n.web"})
public class Application{
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

直接运行main方法即可启动。具体每个注解是啥意思,咋后面再说


pom文件主要配置:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.4.RELEASE</version>
</parent>
  
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-freemarker</artifactId>
    </dependency>
</dependencies>


大家都在看

热门访问