2017-12-25 10 views
1

このサンプルでプロジェクトを開始しましたhttps://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-data-ldap。私は春・ブート・スターター・データ・休息 依存関係を追加するとき、私はapplication.properties (How to disable the default exposure of Spring Data REST repositories?https://github.com/spring-projects/spring-ldap/issues/373)でspring.data.rest.detectionStrategy=annotatedを追加した場合でもSpring LDAPとSpringデータレストとの非互換性

は、しかし、私は PersistentEntity must not be null!エラーが発生しています。 PersonRepositoryで@RepositoryRestResource(exported = false)を試しても同じエラーが出ます。

これはバグですか、何か不足していますか?

おかげ

Person.java:

package sample.data.ldap; 

import javax.naming.Name; 

import org.springframework.ldap.odm.annotations.Attribute; 
import org.springframework.ldap.odm.annotations.Entry; 
import org.springframework.ldap.odm.annotations.Id; 

@Entry(objectClasses = { "person", "top" }) 
public class Person { 

@Id 
private Name dn; 

@Attribute(name = "telephoneNumber") 
private String phone; 

@Override 
public String toString() { 
    return String.format("Customer[dn=%s, phone='%s']", this.dn, this.phone); 
} 
} 

PersonRepository.java:

package sample.data.ldap; 

import org.springframework.data.ldap.repository.LdapRepository; 

public interface PersonRepository extends LdapRepository<Person> { 

Person findByPhone(String phone); 

} 

エラー:

Caused by: java.lang.IllegalArgumentException: PersistentEntity must not be null! 
at org.springframework.util.Assert.notNull(Assert.java:134) 
at org.springframework.data.rest.core.mapping.RepositoryAwareResourceMetadata.<init>(RepositoryAwareResourceMetadata.java:52) 
at org.springframework.data.rest.core.mapping.RepositoryResourceMappings.populateCache(RepositoryResourceMappings.java:90) 
at org.springframework.data.rest.core.mapping.RepositoryResourceMappings.<init>(RepositoryResourceMappings.java:76) 
at org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration.resourceMappings(RepositoryRestMvcConfiguration.java:619) 
at org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration$$EnhancerBySpringCGLIB$$5f6eca9d.CGLIB$resourceMappings$12(<generated>) 
at org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration$$EnhancerBySpringCGLIB$$5f6eca9d$$FastClassBySpringCGLIB$$aab3a667.invoke(<generated>) 
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) 
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358) 
at org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration$$EnhancerBySpringCGLIB$$5f6eca9d.resourceMappings(<generated>) 
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
at java.lang.reflect.Method.invoke(Method.java:498) 
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) 
... 39 more 

のpom.xml:

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

    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-test</artifactId> 
     <scope>test</scope> 
    </dependency> 

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

    <dependency> 
     <groupId>com.unboundid</groupId> 
     <artifactId>unboundid-ldapsdk</artifactId> 
    </dependency> 

    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-data-rest</artifactId> 
    </dependency> 
    </dependencies> 
+0

誰もがリンクされたgithubプロジェクト全体を検索することはありません。あなたは例外を取得しているところにコードスニペットを追加するだけです。 –

答えて

0

これは(LDAP @Entryさんの)Spring Data REST(まだ)で動作していないと思います。 「currently supports JPA, MongoDB, Neo4j, Solr, Cassandra, Gemfire 」。 LDAPの言及はありません。

+0

私はspring.data.rest.detectionStrategy = annotatedを使用してこのリポジトリを無視しています。 PersonRepositoryではなく、別のリポジトリにSpring Data Restを使用したいと思います。 – Keldran

+0

それははっきりしていませんでした。残りのコードを投稿できますか?他のEntity/Repositoryは適切に定義されていますか? – DerM

+0

私はちょうど私の問題を証明するための簡単な例を行った。 @RepositoryRestResource(exported = false)またはspring.data.rest.detectionStrategy = annotatedにもかかわらず、データレストはこのリポジトリを無視しません。私の質問は、Spring Data RestとSpringのLDAPを同じプロジェクトでどうやって使うことができるのですか? – Keldran

0

私もこの問題を抱えており、現在はSpringブートの1.5.xリリースと2.0.0.xマイルストーンバージョンの両方に影響します。私は、JavaとKotlin(1.2.10と1.2.21)の両方で試してみました。そしてSpring-Data-Rest依存関係は子モジュールプロジェクトに限定されていました。

残念ながら、@RepositoryRestResource(exported = false)でアノテートされていても、検出戦略が注釈付きに設定されていても、Spring-Data-RESTはベースのSpring-Dataリポジトリインタフェースを拡張/実装するすべてのものをスキャンしようとします。 LdapRepositoryを拡張し、パッケージ保護された(Java)、内部(Kotlin)、または別のクラスのプライベート静的にスコープされているインタフェースは、依然としてSpring-Data-Restによって取得され、依然としてリソースマッピングエラーを引き起こします。

悪いニュースを申し訳ありませんが、2つのプロジェクトが同じプロジェクトで共存できないように見えます。

これは、回帰Spring-LDAP #373/LDAP-341である可能性があります。

編集:SpringのLDAPテンプレート機能は影響を受けないので、Spring-Data-LDAPをプロジェクトに依存させることができます。 LDAPリポジトリAPIを使用することはできません。

関連する問題