使用eclipse快速新建spirngboot項目的方法
分享兩種eclipse創(chuàng)建spirngboot項目的辦法:
方案一:創(chuàng)建maven項目后修改pom文件
1.用eclipse創(chuàng)建簡單的maven項目
2.修改pom文件
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.chry</groupId>
<artifactId>studySpringBoot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<java.version>1.7</java.version>
</properties>
<!-- Inherit defaults from Spring Boot -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
</parent>
<!-- Add typical dependencies for a web application -->
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<!-- Package as an executable jar -->
<build>
<finalName>studySpringBoot</finalName>
</build>
</project>
3.新建一個類文件
package com.chry.study;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@EnableAutoConfiguration
public class SampleController {
@RequestMapping("/")
@ResponseBody
String home() {
return "Hello World!";
}
public static void main(String[] args) throws Exception {
SpringApplication.run(SampleController.class, args);
}
}
說明:
1.spring-boot-starter-parent:
springboot官方推薦的maven管理工具,最簡單的做法就是繼承它。 spring-boot-starter-parent包含了以下信息:
- 缺省使用java6編譯, 如果需要改為java 1.7,則在pom中加上java.version屬性即可
- 使用utf-8編碼
- 實現(xiàn)了通用的測試框架 (JUnit, Hamcrest, Mockito).
- 智能資源過濾
- 智能的插件配置(exec plugin, surefire, Git commit ID, shade).
2.spring-boot-starter-web
springboot內(nèi)嵌的WEB容器, 缺省會使用tomcat
方案二:在eclipse上安裝STS插件
1、Help -> Eclipse Marketplace
Search或選擇“Popular”標簽,選擇Spring Tool Suite (STS) for Eclipse插件,安裝 或者谷歌百度搜索
2、new project -> 輸入spring 下面會有提示 選擇Spring Starter Project
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
IDEA創(chuàng)建MyBatis配置文件模板的方法步驟
這篇文章主要介紹了IDEA創(chuàng)建MyBatis配置文件模板的方法步驟,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2021-04-04
SpringSecurity OAuth2單點登錄和登出的實現(xiàn)
本文主要介紹了SpringSecurity OAuth2單點登錄和登出的實現(xiàn),文中通過示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2022-02-02
MYSQL批量插入數(shù)據(jù)的實現(xiàn)代碼
非常的實現(xiàn)原理,代碼較多,建議大家仔細看看。2008-10-10
Java中String.format的使用方法總結(jié)
這篇文章主要介紹了Java中String.format的用法總結(jié)的相關(guān)資料,需要的朋友可以參考下2017-03-03

