zoukankan      html  css  js  c++  java
  • springboot项目起步

    两种方式编写pom.xml文件

    继承spring-boot-starter-parent创建项目

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.6.RELEASE</version>
    </parent>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
    </dependencies>
    <!-- SpringBoot应用的打包插件 -->
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
    

    这种方式毕竟适合没有自己的parent的工程项目,如果公司有自己的parent需要继承,那么这种方式就不适合了。

    使用spring-boot-dependencies创建

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-dependencies</artifactId>
                <version>2.0.4.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>   
    
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
    </dependencies>   
    
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
    

    推荐这种方式,这样做比较灵活一点,可以自己再继承parent

    sample类

    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    
    @SpringBootApplication
    public class App {
    	public static void main(String[] args) {
    		
    		SpringApplication.run(App.class, args);
    		
    		System.out.println("Hello World!");
    	}
    }
    
  • 相关阅读:
    Ambari 整体架构
    Ambari 介绍
    xcode工程命令行生成ipa安装包
    gradle打包java项目
    FreeMarker标签介绍
    P与NP,从概念到研究全面综述
    计算机领域经典笑话
    自己动手写GC
    编程语言简史
    不第后赋菊
  • 原文地址:https://www.cnblogs.com/weiguangyue/p/12354481.html
Copyright © 2011-2022 走看看