當前位置:
首頁 >
前端技术
> javascript
>内容正文
javascript
SpringBoot:spring-boot-starter-parent
生活随笔
收集整理的這篇文章主要介紹了
SpringBoot:spring-boot-starter-parent
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
你的項目pom.xml文件中,應該存在如下代碼:
<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.0.0.RELEASE</version> </parent>你是否知道這是干啥的?
這是Spring Boot的父級依賴,這樣當前的項目就是Spring Boot項目了。
spring-boot-starter-parent 是一個特殊的starter,它用來提供相關的Maven默認依賴。使用它之后,常用的包依賴可以省去version標簽。
當我們搭建web應用的時候,可以像下面這樣添加spring-boot-starter-web依賴:
<dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency> </dependencies>簡單的演示下 Spring Boot 項目:
maven文件看起來是這個樣子的:
<?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>springBootLearn</groupId><artifactId>springBootLearn</artifactId><version>1.0-SNAPSHOT</version><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.0.0.RELEASE</version></parent><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency></dependencies> </project>HelloworldController.java
@RestController public class HelloworldController {@RequestMapping("/")public String say(){return "Hello Spring Boot";} }Application.java
@SpringBootApplication public class Application {public static void main(String[] args) {SpringApplication.run(Ch1Application.class, args);} }運行main方法,啟動項目,然后在瀏覽器訪問http://localhost:8080,就能看到 "Hello Spring Boot"。
總結
以上是生活随笔為你收集整理的SpringBoot:spring-boot-starter-parent的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 远程抓取Linux服务器上的数据包
- 下一篇: 获取application.yml中的属