【发布时间】:2015-05-02 07:13:54
【问题描述】:
我正在使用最新版本的 spring-boot 并尝试将 id 添加到我的 json 实体中,如 here 所述
如果我添加此配置,我的 JSON 响应将不再有效:
2015-03-02 11:55:13.949 DEBUG 8288 --- [nio-8080-exec-1] o.s.b.a.e.mvc.EndpointHandlerMapping : Looking up handler method for path /hal/tutorials/1
2015-03-02 11:55:13.951 DEBUG 8288 --- [nio-8080-exec-1] o.s.b.a.e.mvc.EndpointHandlerMapping : Did not find handler method for [/hal/tutorials/1]
2015-03-02 11:55:13.974 DEBUG 8288 --- [nio-8080-exec-1] o.s.b.a.e.mvc.EndpointHandlerMapping : Looking up handler method for path /error
2015-03-02 11:55:13.975 DEBUG 8288 --- [nio-8080-exec-1] o.s.b.a.e.mvc.EndpointHandlerMapping : Did not find handler method for [/error]
这是我的主要配置文件,我尝试将RepositoryConfig 移动到它自己的文件中并使用@Component 而不是@Configuration,但没有任何效果。
@SpringBootApplication
@EntityScan(basePackages = { "com.mypp.domain" })
@EnableJpaRepositories(basePackages = { "com.mypp.repository" })
@EnableTransactionManagement
@EnableGlobalMethodSecurity
@EnableJpaAuditing
@EnableConfigurationProperties
public class ShelltorialsApplication {
public static void main(String[] args) {
SpringApplication.run(ShelltorialsApplication.class, args);
}
}
@Configuration
public class RepositoryConfig extends
RepositoryRestMvcConfiguration {
@Override
protected void configureRepositoryRestConfiguration(
RepositoryRestConfiguration config) {
config.exposeIdsFor(Tutorial.class);
}
}
我做错了什么?
【问题讨论】:
-
在添加 RepositoryConfig 之前你的 baseuri 是如何配置的?
标签: spring-boot spring-data-rest