Reputation: 1423
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"
}
}
}
Please find below 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
My repository class is as follows:
public interface UsrAccessRepository extends PagingAndSortingRepository<UsrAccess, Long>{
List<UsrAccess> findByUserId(@Param("userId") String userId);
//
List<UsrAccess> findAll();
}
When I access the following url http://localhost:8080/findAll a 404 error is thrown.
I used this example as tutorial: https://www.baeldung.com/spring-data-rest-intro
Any idea what i am missing here please?
Upvotes: 0
Views: 764
Reputation: 3423
Your UsrAccessRepository.java
must be in the same package-tree than your main class (annotated by @SpringBootApplication
).
By default Spring-Data-Rest only scan for repository-interfaces in- and under the main class's package.
If your repository is an other package then use @ComponentScan
Upvotes: 1