![](/img/trans.png)
[英]Problem hitting REST endpoint in Spring Boot 2.2.0 application
[英]Spring boot (2.2.0.RELEASE<) with spring data rest endpoint not exposed
I am new to spring data rest and I have my application deployed on my PC but when I access the url( http://localhost:8080/ ) the following json is displayed without the method exposed in my repository:
{
"_links" : {
"profile" : {
"href" : "http://localhost:8080/profile"
}
}
}
请在下面找到 application.properties:
spring.datasource.url=jdbc:oracle:thin:@test:test1
spring.datasource.username=dummy
spring.datasource.password=dummy
spring.datasource.driver=class-oracle.jdbc.driver.OracleDriver
# HikariCP settings
# spring.datasource.hikari.*
spring.datasource.hikari.connection-timeout=60000
spring.datasource.hikari.maximum-pool-size=5
spring.main.allow-bean-definition-overriding=true
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
我的存储库 class 如下:
public interface UsrAccessRepository extends PagingAndSortingRepository<UsrAccess, Long>{
List<UsrAccess> findByUserId(@Param("userId") String userId);
//
List<UsrAccess> findAll();
}
当我访问以下 url http://localhost:8080/findAll时,会抛出 404 错误。
我将此示例用作教程: https://www.baeldung.com/spring-data-rest-intro
知道我在这里缺少什么吗?
您的UsrAccessRepository.java
必须与您的主 class 位于同一包树中(由@SpringBootApplication
注释)。
默认情况下,Spring-Data-Rest 仅扫描主类 package 中和下的存储库接口。
如果您的存储库是其他 package 则使用@ComponentScan
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.