私はスプリングブートアプリケーションを作成しようとしています。私のアプリケーションでは、デフォルトのsaveメソッドを使用する代わりに、データを保存するカスタムメソッドをいくつか追加したいと考えています。私もImplをしかし、それは動作しませんでしたし、このラインrepositoryImplementationPostfixを変更したSpring Data JPAカスタムメソッドPropertyReferenceExceptionの原因
@Configuration
@ComponentScan
@EnableJpaRepositories(repositoryImplementationPostfix = "CustomImpl")
@Import(RepositoryRestMvcConfiguration.class)
@EnableAutoConfiguration
@PropertySource("application.properties")
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
:
私のアプリケーションのエントリポイントは次のようなものです。
マイCrudRepository
@RepositoryRestResource
public interface TaRepository extends CrudRepository<Ta, Integer> ,TestRepository{
List<Ta> findByName(@Param("name") String name);
}
マイカスタムリポジトリ:
public interface TestRepository {
public void myCustomMethod(TestDto dto);
}
マイカスタムリポジトリのImpl
public class TestRepositoryCustomImpl implements TestRepository{
@PersistenceContext
private EntityManager em;
@Override
public void myCustomMethod(TestDto model){
}
NOTE:
私はこれに言及したから私のCrudRepostoryを変更する場合:
@RepositoryRestResource
public interface TaRepository extends CrudRepository<Ta, Integer> {
List<Ta> findByName(@Param("name") String name);
}
すべてが正常に動作します。しかし、カスタムメソッドの実装ではありません。
これはなんですか?エラーはありますか? – nurgasemetey
原因:org.springframework.data.mapping.PropertyReferenceException:タイプTaのmyCustomMethodプロパティが見つかりませんでした! –
http://stackoverflow.com/questions/20777785/org-springframework-data-mapping-propertyreferenceexception-no-property-catch-f - このリンクでは、 'TestRepositoryCustomImpl'を' TaRepositoryCustomImpl'に、 'TestRepository'を'TaRepositoryCustom' – nurgasemetey