2017-08-31 121 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

相关问题