I'm writing a rest service with spring-data-rest. And I face an exception that I don't know how to fix.
I have the following Application configuration
@Configuration
@ComponentScan(basePackageClasses = Application.class)
@EnableJpaRepositories
@EnableTransactionManagement
public class Application {
@Bean
public DataSource dataSource() {
return new EmbeddedDatabaseBuilder().setType(H2).build();
}
@Bean
public CustomerLoader loadCustomers() {
return new CustomerLoader();
}
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource, JpaVendorAdapter jpaVendorAdapter) {
LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean();
lef.setDataSource(dataSource);
lef.setJpaVendorAdapter(jpaVendorAdapter);
lef.setPackagesToScan("hello");
return lef;
}
@Bean
public JpaVendorAdapter jpaVendorAdapter() {
HibernateJpaVendorAdapter hibernateJpaVendorAdapter = new HibernateJpaVendorAdapter();
hibernateJpaVendorAdapter.setShowSql(false);
hibernateJpaVendorAdapter.setGenerateDdl(true);
hibernateJpaVendorAdapter.setDatabase(Database.H2);
return hibernateJpaVendorAdapter;
}
@Bean
public PlatformTransactionManager transactionManager() {
return new JpaTransactionManager();
}
And This is my WebApplication initializer
@Override
public void onStartup(ServletContext ctx)
throws ServletException {
AnnotationConfigWebApplicationContext rootCtx = new AnnotationConfigWebApplicationContext();
rootCtx.register(Application.class);
ctx.addListener(new ContextLoaderListener(rootCtx));
RepositoryRestExporterServlet exporter = new RepositoryRestExporterServlet();
ServletRegistration.Dynamic reg = ctx.addServlet("exporter", exporter);
reg.setLoadOnStartup(1);
reg.addMapping("/*");
}
When I run my application on server I get the following exception on Servlet.init()
SEVERE: Servlet /spring-data-rest threw load() exception
java.lang.NoSuchMethodError: org.springframework.data.rest.webmvc.ResourceProcessorInvokingHandlerAdapter.getReturnValueHandlers()Lorg/springframework/web/method/support/HandlerMethodReturnValueHandlerComposite;
(if you want the full stacktrace please tell)
I thought it would be some class loading issue due to some jar duplication. But I'm building my project with maven and I'm using only one repository (http://repo.spring.io/libs-milestone) with parent pom spring-boot-starter-parent version 0.5.0.M5