2017-03-05 26 views
0

所有Spring Boot sample projects都有父項目spring-boot-samples,它不在中央maven存儲庫中。所以,如果我開始基於任何spring引導示例項目創建我的應用程序,那麼我的應用程序應該有spring-boot-samples作爲父項目。擺脫作爲父項目的spring-boot-samples

什麼是擺脫spring-boot-samples項目作爲應用程序的父項目的常用方法?

+0

使用http://start.spring.io創建一個框架項目庫,而不是使用示例項目。 – Gregg

+0

春季啓動示例項目更具有延伸性。例如[spring-boot-sample-web-secure](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-web-secure)包含簡單的安全配置java代碼,同時在start.spring.io項目中添加「安全性」將只添加相關的依賴關係到pom.xml。 – user3705896

回答

1

爲了運行您的應用程序作爲彈簧啓動應用程序,您需要提供提示(依賴關係)到您的應用程序。

哪個,

<parent> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-parent</artifactId> 
     <version>2.0.0.BUILD-SNAPSHOT</version> 
     <relativePath>../spring-boot-starters/spring-boot-starter-parent</relativePath> 
    </parent> 

在你的情況彈簧引導樣本是爲您提供春季啓動應用程序的支持。怎麼樣?

打開其工件ID爲​​pom.xml中,

spring-boot-samples

在這裏你可以找到上面提到的彈簧引導標識(彈簧引導啓動父)作爲一個家長彈簧啓動示例

因此,如果您希望擺脫所述父級,則必須將此依賴項作爲父級添加到當前應用程序中。

spring-boot-starter-parent

參考(按順序):

  1. https://github.com/spring-projects/spring-boot/blob/master/spring-boot-samples/spring-boot-sample-web-secure/pom.xml
  2. https://github.com/spring-projects/spring-boot/blob/master/pom.xml

注:回覆中,如果鐵道部評論需要的信息。