簡単な回答: Spring Framework を少なくとも 4.0.4 に更新します。
これは私にはバグのように聞こえSpring Data Commonsます。と の順序に応じて、@EnableSolrRepositoriesSpring@EnableJpaRepositoriesはsolrOperationsonJpaRepositoryFactoryBeanまたは
entityManageron のいずれかに設定しようとしSolrRepositoryFactoryBeanます。
EnableSolrRepositories前EnableJpaRepositories
@Configuration
@EnableSolrRepositories("package.a")
@EnableJpaRepositories("package.b")
@EnableTransactionManagement
public class MyConfig {
...
}
結果は
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'solrOperations' of bean class [org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean]: Bean property 'solrOperations' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1064)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:922)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:82)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:62)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1489)
... 107 more
EnableJpaRepositories前EnableSolrRepositories
@Configuration
@EnableJpaRepositories("package.b")
@EnableSolrRepositories("package.a")
@EnableTransactionManagement
public class MyConfig {
...
}
結果は
Caused by: org.springframework.beans.NotWritablePropertyException: Invalid property 'entityManager' of bean class [org.springframework.data.solr.repository.support.SolrRepositoryFactoryBean]: Bean property 'entityManager' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1064)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:922)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:82)
at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:62)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1489)
... 77 more
最新の Spring Data リリースを使用しています
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>1.6.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-solr</artifactId>
<version>1.2.1.RELEASE</version>
</dependency>
補足として
このエラーは、同じ構成クラスを使用しているテストでは発生しません。
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {MyConfig.class})
@Transactional
public class MyTest {
....
}
Tomcat での展開中にのみ発生します (私のバージョンは 7.0.54 です)。誰かが同じ問題を経験しましたか?