2015-12-02 53 views
2

我是Spring Boot的新成員,未能創建自包含的可執行jar。 Maven創建的jar無法檢測到它在運行時需要的Beans。Spring Boot:我如何創建一個自包含的可執行jar?

Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean. 

我檢查了工廠,如果工廠的實施是在這種情況下的罐子。我還仔細檢查了其他帖子,並確保Spring Boot註釋已到位。它包括@ComponentScan和其他。

@SpringBootApplication 
public class InitService { 

我認爲我的POM具有正確設置的依賴關係,因爲應用程序運行正常,當我從我的Eclipse項目啓動它。

<build> 
    <plugins> 
     <plugin> 
      <artifactId>maven-assembly-plugin</artifactId> 
      <configuration> 
       <archive> 
        <manifest> 
         <mainClass>de.newbe.create.InitService</mainClass> 
        </manifest> 
       </archive> 
       <descriptorRefs> 
        <descriptorRef>jar-with-dependencies</descriptorRef> 
       </descriptorRefs> 
      </configuration> 
      <executions> 
       <execution> 
        <id>make-assembly</id> <!-- this is used for inheritance merges --> 
        <phase>package</phase> <!-- bind to the packaging phase --> 
        <goals> 
         <goal>single</goal> 
        </goals> 
       </execution> 
      </executions> 
     </plugin> 
    </plugins> 
</build> 

因此,現在我向社區提出挑戰,希望爲您提供寶貴的專業知識和支持。提前致謝!

+0

Maven的組件,插件似乎是春天引導錯誤的選擇將無法檢測到的罐子。相反,Mathias指出,需要spring-boot-maven-plugin。 – otembajelle

回答

4
+0

哇,太棒了。它解決了我的問題。謝謝! – otembajelle

+0

爲什麼不upvote anser然後;-) –

+0

他們不會讓我馬蒂亞斯。我沒有積分:( – otembajelle

相關問題