2
**編集:mavenの代わりにgradleを使用すると正常に動作しますが、私は最初からプロジェクトを生成します。 spring.iojarを実行しているのにIDEから正常に動作しているときのスプリングブートエラー
** EDIT2:私のpom.xml
<?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"
\t xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
\t <modelVersion>4.0.0</modelVersion>
\t <groupId>org.mywebsite</groupId>
\t <artifactId>myprojectname</artifactId>
\t <version>0.0.1-SNAPSHOT</version>
\t <packaging>jar</packaging>
\t <name>myprojectname</name>
\t <description>xxx</description>
\t <parent>
\t \t <groupId>org.springframework.boot</groupId>
\t \t <artifactId>spring-boot-starter-parent</artifactId>
\t \t <version>1.4.0.RELEASE</version>
\t \t <relativePath /> <!-- lookup parent from repository -->
\t </parent>
\t <properties>
\t \t <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
\t \t <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
\t \t <java.version>1.8</java.version>
\t </properties>
\t <dependencies>
\t \t <dependency>
\t \t \t <groupId>org.springframework.boot</groupId>
\t \t \t <artifactId>spring-boot-starter-hateoas</artifactId>
\t \t </dependency>
\t \t <dependency>
\t \t \t <groupId>org.springframework.restdocs</groupId>
\t \t \t <artifactId>spring-restdocs-mockmvc</artifactId>
\t \t \t <scope>test</scope>
\t \t </dependency>
\t \t <dependency>
\t \t \t <groupId>org.springframework.boot</groupId>
\t \t \t <artifactId>spring-boot-starter-data-jpa</artifactId>
\t \t </dependency>
\t \t <dependency>
\t \t \t <groupId>org.springframework.boot</groupId>
\t \t \t <artifactId>spring-boot-starter-data-rest</artifactId>
\t \t </dependency>
\t \t <dependency>
\t \t \t <groupId>org.springframework.boot</groupId>
\t \t \t <artifactId>spring-boot-starter-thymeleaf</artifactId>
\t \t </dependency>
\t \t <dependency>
\t \t \t <groupId>org.springframework.boot</groupId>
\t \t \t <artifactId>spring-boot-starter-web</artifactId>
\t \t </dependency>
\t \t <dependency>
\t \t \t <groupId>org.springframework.boot</groupId>
\t \t \t <artifactId>spring-boot-starter-actuator</artifactId>
\t \t </dependency>
\t \t <dependency>
\t \t \t <groupId>com.h2database</groupId>
\t \t \t <artifactId>h2</artifactId>
\t \t \t <scope>runtime</scope>
\t \t </dependency>
\t \t <dependency>
\t \t \t <groupId>org.springframework.boot</groupId>
\t \t \t <artifactId>spring-boot-starter-test</artifactId>
\t \t \t <scope>test</scope>
\t \t </dependency>
\t </dependencies>
\t <build>
\t \t <plugins>
\t \t \t <plugin>
\t \t \t \t <groupId>org.springframework.boot</groupId>
\t \t \t \t <artifactId>spring-boot-maven-plugin</artifactId>
\t \t \t </plugin>
\t \t </plugins>
\t </build>
</project>
私はのEclipse IDEからの私のコードの作業[OK]を実行しますが、私はの.jarとしてプロジェクトをパッケージ化し、このエラーを示したコマンドラインから実行すると、 もし私がspring-boot-starter-data-jpaを依存関係から削除しても問題ないです。
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: Unable to resolve persistence unit root URL
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578) ~[spring-beans-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545) ~[spring-beans-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1076) ~[spring-context-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:851) ~[spring-context-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) ~[spring-context-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.4.1.BUILD-SNAPSHOT.jar!/:1.4.1.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-1.4.1.BUILD-SNAPSHOT.jar!/:1.4.1.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:369) [spring-boot-1.4.1.BUILD-SNAPSHOT.jar!/:1.4.1.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:313) [spring-boot-1.4.1.BUILD-SNAPSHOT.jar!/:1.4.1.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1185) [spring-boot-1.4.1.BUILD-SNAPSHOT.jar!/:1.4.1.BUILD-SNAPSHOT]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1174) [spring-boot-1.4.1.BUILD-SNAPSHOT.jar!/:1.4.1.BUILD-SNAPSHOT]
at org.betterworldinternational.TheGoodCards2Application.main(TheGoodCards2Application.java:10) [classes!/:0.0.1-SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_101]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_101]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_101]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_101]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [ward.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [ward.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [ward.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:58) [ward.jar:0.0.1-SNAPSHOT]
Caused by: javax.persistence.PersistenceException: Unable to resolve persistence unit root URL
at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.determineDefaultPersistenceUnitRootUrl(DefaultPersistenceUnitManager.java:603) ~[spring-orm-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.preparePersistenceUnitInfos(DefaultPersistenceUnitManager.java:443) ~[spring-orm-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.afterPropertiesSet(DefaultPersistenceUnitManager.java:424) ~[spring-orm-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean.createNativeEntityManagerFactory(LocalContainerEntityManagerFactoryBean.java:310) ~[spring-orm-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.buildNativeEntityManagerFactory(AbstractEntityManagerFactoryBean.java:373) ~[spring-orm-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.afterPropertiesSet(AbstractEntityManagerFactoryBean.java:362) ~[spring-orm-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637) ~[spring-beans-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574) ~[spring-beans-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
... 24 common frames omitted
Caused by: java.io.FileNotFoundException: class path resource [] cannot be resolved to URL because it does not exist
at org.springframework.core.io.ClassPathResource.getURL(ClassPathResource.java:187) ~[spring-core-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
at org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.determineDefaultPersistenceUnitRootUrl(DefaultPersistenceUnitManager.java:600) ~[spring-orm-4.3.2.RELEASE.jar!/:4.3.2.RELEASE]
... 31 common frames omitted
JPA永続性ユニットが空です。つまり、エンティティがないか、エンティティが見つからないということです。単なるスタックトレースからどれを知ることは不可能です。 –
それは奇妙です..私はそれが大丈夫に動作するのmavenの代わりにgradleを使用するとき、私はstart.spring.ioから私のプロジェクトを生成する – Ward
あなたはpom.xmlを投稿してください。 – Ozilophile