springboot小笔记

如果默认通过IDEA的springboot 插件布置的 的初始启动类是这样的,这种就是一个普通的java类,只能以jar打包

package com.how2java.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class SpringbootApplication {


    public static void main(String[] args) {
        SpringApplication.run(SpringbootApplication.class, args);


    }
}

假如想以打包成war包, 想放到tomcat 的webapp里 那么改成下面这个启动类

package com.how2java.springboot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

@SpringBootApplication
@ServletComponentScan
public class Application extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(Application.class);
    }

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }
}

新建的 Spring-Boot没有WEB-INF 目录

https://blog.csdn.net/CASER_HDMI/article/details/78570615

posted @ 2018-07-17 22:08  Pororo  阅读(156)  评论(0编辑  收藏  举报