Spring Boot打包jar或war

Spring Boot + MyBatis 的提供类别和文章相关crud接口和爬取其他网站数据接口的Demo: https://github.com/Qbian61/SpringBoot-MyBatis

打jar包


<packaging>jarpackaging>


<dependencies>
    <dependency>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-webartifactId>
    dependency>
dependencies>


@SpringBootApplication
public class Application {

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

}

打war包


<packaging>warpackaging>


<properties>
    <tomcat.version>7.0.59tomcat.version>
properties>


<dependencies>
    <dependency>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-webartifactId>
        
        <exclusions>
            <exclusion>
                <groupId>org.springframework.bootgroupId>
                <artifactId>spring-boot-starter-tomcatartifactId>
            exclusion>
        exclusions>
    dependency>
    
    <dependency>
        <groupId>org.apache.tomcatgroupId>
        <artifactId>tomcat-juliartifactId>
        
        <version>${tomcat.version}version>
    dependency>
    <dependency>
        <groupId>org.springframework.bootgroupId>
        <artifactId>spring-boot-starter-tomcatartifactId>
        
        <scope>providedscope>
    dependency>
dependencies>


@SpringBootApplication
public class Application extends SpringBootServletInitializer {

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

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

}

你可能感兴趣的:(Java)