2017-08-31 75 views
1

我有一個使用JavaFX的Spring Boot項目。當我運行這個項目的想法,一切工作正常,但經過使用Maven我包項目我得到嘗試運行jar文件創建一個bean時出錯「entityManagerFactory」

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' 
Invocation of init method failed;nested exception is java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException 

的pom.xml此異常時此

<dependencies> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-data-jpa</artifactId> 
    </dependency> 

    <dependency> 
     <groupId>com.h2database</groupId> 
     <artifactId>h2</artifactId> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-test</artifactId> 
     <scope>test</scope> 
    </dependency> 
</dependencies> 

回答

2

嘗試增加這些依賴關係到您的POM:

<dependency> 
    <groupId>javax.xml.bind</groupId> 
    <artifactId>jaxb-api</artifactId> 
</dependency> 

<dependency> 
    <groupId>com.sun.xml.bind</groupId> 
    <artifactId>jaxb-impl</artifactId> 
</dependency> 

也許您需要爲軟件包添加版本。

+1

其實幫忙,謝謝!也許你也知道爲什麼方法註釋@PostConstruct不運行?同樣的問題,在想法中工作,在jar文件中不起作用。 – EmberTraveller

+0

@EmberTraveller我不認爲這個問題與第一個有關...試着問一個新的問題。但可能有一些依賴關係丟失... – davioooh

相關問題