小编Kaz*_*izu的帖子

@JdbcTest 检测注释为 @SpringBootApplication 的类

我已经尝试过@JdbcTest以下项目结构。

\n\n
.\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 pom.xml\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 src\n    \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 main\n    \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 java\n    \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 com\n    \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0     \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 example\n    \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0         \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Application.java\n    \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0         \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 repository\n    \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0         \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 DemoRepository.java\n    \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0         \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 service\n    \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x82\xc2\xa0\xc2\xa0             \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 DemoService.java\n    \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 resources\n    \xe2\x94\x82\xc2\xa0\xc2\xa0     \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 application.properties\n    \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 test\n        \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 java\n            \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 com\n                \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 example\n                    \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 ApplicationTests.java\n                    \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 repository\n                        \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 DemoRepositoryTests.java\n
Run Code Online (Sandbox Code Playgroud)\n\n

DemoRepository.java(测试目标)

\n\n
package com.example.repository;\n\nimport org.springframework.jdbc.core.JdbcOperations;\nimport org.springframework.stereotype.Repository;\n\n@Repository\npublic class DemoRepository {\n\n    private final JdbcOperations jdbcOperations;\n\n    DemoRepository(JdbcOperations jdbcOperations) {\n        this.jdbcOperations = …
Run Code Online (Sandbox Code Playgroud)

spring-boot spring-boot-test

5
推荐指数
1
解决办法
6750
查看次数

标签 统计

spring-boot ×1

spring-boot-test ×1