2016-08-15 3 views
0

私は自分のプロジェクトでspring-boot-starter-data-neo4jを使用しています。 Java 10を搭載したWindows 10のEclipseで開発中です。 neo4jサーバーは別のマシン(10.10.10.6)にあります。エラースプリングデータNeo4jがドッカーイメージ

Windowsでは、コンパイル、パッケージ、およびビルドイメージはOKです。実行イメージはエラーなし。

DebianのqEmuイメージの下で、私はエラーに直面しています。

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.rest.core.mapping.RepositoryResourceMappings]: Factory method 'resourceMappings' threw exception; nested exception is java.lang.IllegalArgumentException: PersistentEntity must not be null! 
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.3.2.RELEASE.jar!/:4.3.2.RELEASE] 
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.3.2.RELEASE.jar!/:4.3.2.RELEASE] 
    ... 41 common frames omitted 
Caused by: java.lang.IllegalArgumentException: PersistentEntity must not be null! 
    at org.springframework.util.Assert.notNull(Assert.java:115) ~[spring-core-4.3.2.RELEASE.jar!/:4.3.2.RELEASE] 

マイapplication.yml:

spring: 
    jackson: 
    serialization: 
     WRITE_DATES_AS_TIMESTAMPS: false 

neo4j: 
    user: neo4j 
    password: neo4j 
    url: http://10.10.10.6:7474/ 

server: 
    port: 8080 

マイ設定:

@SpringBootApplication 
@EnableTransactionManagement 
@EnableNeo4jRepositories(basePackages = "com.referentielneo4j.data.repositories") 
@Slf4j 
public class Referentielneo4jApplication extends Neo4jConfiguration { 

    public static void main(String[] args) { 
     SpringApplication.run(Referentielneo4jApplication.class, args); 
    } 

    @Bean 
    public org.neo4j.ogm.config.Configuration getConfiguration() { 
     org.neo4j.ogm.config.Configuration config = new org.neo4j.ogm.config.Configuration(); 
     config.driverConfiguration().setDriverClassName("org.neo4j.ogm.drivers.http.driver.HttpDriver"); 
     config.driverConfiguration().setURI("http://neo4j:[email protected]:7474"); 
     return config; 
    } 

    @Bean 
    public SessionFactory getSessionFactory() { 
     return new SessionFactory(getConfiguration(), "com.referentielneo4j.data.model"); 
    } 

    public Session getSession() throws Exception { 
     return super.getSession(); 
    } 

    @Bean 
    ApplicationListener<BeforeSaveEvent> beforeSaveEventApplicationListener() { 
     return new ApplicationListener<BeforeSaveEvent>() { 
      @Override 
      public void onApplicationEvent(BeforeSaveEvent event) { 
       Object entity = event.getEntity(); 
       log.debug("Before save of: " + entity); 
      } 
     }; 
    } 

    @Bean 
    ApplicationListener<AfterSaveEvent> afterSaveEventApplicationListener() { 
     return new ApplicationListener<AfterSaveEvent>() { 
      @Override 
      public void onApplicationEvent(AfterSaveEvent event) { 
       Object entity = event.getEntity(); 
       log.debug("Before save of: " + entity); 
      } 
     }; 
    } 

    @Bean 
    ApplicationListener<AfterDeleteEvent> deleteEventApplicationListener() { 
     return new ApplicationListener<AfterDeleteEvent>() { 
      @Override 
      public void onApplicationEvent(AfterDeleteEvent event) { 
       Object entity = event.getEntity(); 
       log.debug("Before save of: " + entity); 
      } 
     }; 
    } 
} 

私のpom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>sample</groupId> 
    <artifactId>referentielneo4j</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>jar</packaging> 

    <name>referentielneo4j</name> 
    <description>Demo project for Spring Boot</description> 

    <parent> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-parent</artifactId> 
     <version>1.4.0.RELEASE</version> 
     <relativePath /> <!-- lookup parent from repository --> 
    </parent> 

    <properties> 
     <java.version>1.8</java.version> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
     <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 
     <ogm.driver.version>2.1.0-SNAPSHOT</ogm.driver.version> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-web</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-aop</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-jersey</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-data-rest</artifactId> 
     </dependency> 
     <dependency> 
      <groupId>org.projectlombok</groupId> 
      <artifactId>lombok</artifactId> 
     </dependency> 

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

     <dependency> 
      <groupId>com.voodoodyne.jackson.jsog</groupId> 
      <artifactId>jackson-jsog</artifactId> 
      <version>1.1</version> 
      <scope>compile</scope> 
     </dependency> 

     <dependency> 
      <groupId>org.springframework.data</groupId> 
      <artifactId>spring-data-commons</artifactId> 
      <version>1.12.0.BUILD-SNAPSHOT</version> 
     </dependency> 
     <dependency> 
      <groupId>org.neo4j</groupId> 
      <artifactId>neo4j-ogm-embedded-driver</artifactId> 
      <version>2.0.4</version> 
      <!-- <version>{ogm-version}</version> --> 
     </dependency> 

    </dependencies> 

    <build> 
     <plugins> 
      <plugin> 
       <artifactId>maven-compiler-plugin</artifactId> 
      </plugin> 
      <plugin> 
       <groupId>org.springframework.boot</groupId> 
       <artifactId>spring-boot-maven-plugin</artifactId> 
      </plugin> 
     </plugins> 
    </build> 

    <repositories> 
     <repository> 
      <id>spring-milestones</id> 
      <url>http://repo.spring.io/libs-snapshot</url> 
      <snapshots> 
       <enabled>true</enabled> 
      </snapshots> 
     </repository> 
    </repositories> 
    <pluginRepositories> 
     <pluginRepository> 
      <id>spring-milestones</id> 
      <url>http://repo.spring.io/libs-snapshot</url> 
      <snapshots> 
       <enabled>true</enabled> 
      </snapshots> 
     </pluginRepository> 
    </pluginRepositories> 
</project> 

マイDockerfile

FROM java:openjdk-8-jre-alpine 
MAINTAINER XXXXX XXXXX <[email protected]> 

ADD target/referentielneo4j-0.0.1-SNAPSHOT.jar /app/referentielneo4j.jar 
ADD application.yml /conf/application.yml 

CMD java -Djava.security.egd=file:/dev/./urandom -jar /app/referentielneo4j.jar --spring.config.location=file:/conf/application.yml --debug 

EXPOSE 8080 

アイデアはありますか?

答えて

0

問題はDockerではありません。Neo4Jは実行可能アーカイブでエンティティを見つけることができません。このバグを回避するには

あなたは、このようなあなたのアプリケーションファイルにbasePackageを追加する必要があります:この回避策はここにGithub issue

を説明している

@Bean 
public SessionFactory getSessionFactory() { 
    return new SessionFactory(getConfiguration(), "com.referentielneo4j.data.model", "BOOT-INF.classes.com.referentielneo4j.data.model"); 
} 

関連する問題