Myeclipse建立spring boot
阿新 • • 發佈:2019-01-06
1.maven匯入
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.0.RELEASE</version>
<relativePath />
</parent>
<!-- 對web開發的支援,包括tomcat,spring-webmvc --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- spring boot核心,包括自動配置支援,日誌和YAML --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> </dependency> <!-- DevTools in Spring Boot 專案熱部署 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> </dependency>
2.在src/main/java下建立一個包在建立一個class,記得不要直接在src/main/java下建立這個class不然會報錯
這個用於啟動spring boot專案import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class MyFirstSpringBoot { public static void main(String[] args) { SpringApplication.run(MyFirstSpringBoot.class, args); } }
3.在src/main/resources下建立
這個是spring boot 的配置檔案
4.會報錯