天天看點

使用maven快速建立一個springboot項目

快速建立一個springboot項目

工具:STS

1.在STS建立一個maven項目,new->maven project

2.在pom.xml中加入springboot的相關依賴

//和propertise同級

<parent>

  <groupId>org.springframework.boot</groupId>

  <artifactId>spring-boot-starter-parent</artifactId>

  <version>1.5.9.RELEASE</version>

</parent>

//springboot依賴

<dependency>

   <groupId>org.springframework.boot</groupId>

   <artifactId>spring-boot-starter-web</artifactId>

   <version>1.5.9.release</version> 

</dependency>

3.webStarter.java啟動檔案,加入啟動springboot項目的注解@SpringBootApplication

@SpringBootApplication

public class CoxFitsWebStarter {

    public static void main(String[] args) {

     TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));

     SpringApplicationBuilder sab = new SpringApplicationBuilder();

     sab.sources(WebStarter.class);

     sab.web(true);

     sab.run(args);

    }

}

4、建立一個包src/main/resources,裡面兩個分包config和static

config用來放配置檔案:application.properties

static用來放靜态檔案資源

繼續閱讀