未公开Spring数据其余端点的Spring Boot(2.2.0.RELEASE <)

时间:2019-10-24 12:41:34

标签: java rest spring-boot spring-data-jpa

我不熟悉Spring Data Rest,并且将应用程序部署在PC上,但是当我访问url(http://localhost:8080/)时,会显示以下json,而未在存储库中公开该方法:

make

请在下面找到application.properties:

{
  "_links" : {
    "profile" : {
      "href" : "http://localhost:8080/profile"
    }
  }
}

我的存储库类如下:

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

当我访问以下网址http://localhost:8080/findAll时,将引发404错误。

我将此示例用作教程: https://www.baeldung.com/spring-data-rest-intro

你知道我在这里想念什么吗?

1 个答案:

答案 0 :(得分:0)

您的UsrAccessRepository.java必须与主类位于同一包树中(由@SpringBootApplication注释)。

默认情况下,Spring-Data-Rest仅在主类的包内和下扫描存储库接口。

如果您的存储库是其他软件包,请使用@ComponentScan