- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用@DataJpaTest 注释创建了一个测试。 hsqldb 已配置,但出现错误:
No qualifying bean of type [org.springframework.jdbc.core.JdbcTemplate]
在项目中,我使用了 JPA 存储库和 JdbcTemplates。当我使用真正的 Oracle 数据库配置时,它工作正常。为什么 JdbcTemplate 没有自动配置?我应该怎么做才能解决这个问题?
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {MyApplication.class})
@DataJpaTest
public class IntegrationTest
依赖关系:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>args4j</groupId>
<artifactId>args4j</artifactId>
<version>2.33</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-remote-shell</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3.0</version>
</dependency>
<dependency>
<groupId>com.netflix.hystrix</groupId>
<artifactId>hystrix-core</artifactId>
<version>1.4.18</version>
</dependency>
<dependency>
<groupId>org.perf4j</groupId>
<artifactId>perf4j</artifactId>
<version>0.9.16</version>
</dependency>
<dependency>
<groupId>io.reactivex</groupId>
<artifactId>rxjava</artifactId>
<version>1.0.13</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.2.3.RELEASE</version>
</dependency>
属性:
spring.jpa.database=ORACLE
spring.jpa.show-sql=false
spring.jpa.hibernate.ddl-auto=validate
spring.datasource.driverClassName=oracle.jdbc.OracleDriver
spring.datasource.url=..
spring.datasource.username=..
spring.datasource.password=..
spring.datasource.max-active=20
spring.datasource.max-idle=5
spring.datasource.min-idle=1
spring.datasource.initial-size=5
spring.datasource.testWhileIdle = true
spring.datasource.timeBetweenEvictionRunsMillis = 20000
#spring.datasource.test-on-borrow=true
spring.datasource.validation-query=select 1 from dual;
spring.jpa.properties.hibernate.order_inserts=true
spring.jpa.properties.hibernate.order_updates=true
spring.jpa.properties.hibernate.jdbc.batch_size=100
spring.jpa.properties.hibernate.cache.use_second_level_cache=false
最佳答案
目前还没有配置。我有 already answered how to create your own slice我最近写了a blog post about it .
JdbcTemplate
没有配置 DataJpaTest
没有特别的原因。该注释的主要用例是测试您的 JPA 数据层。当你这样做时,你可能不应该使用 JdbcTemplate
但我知道你可能喜欢在你的测试中改变数据库或其他东西?
我创建了 #6802要跟踪您的请求,请关注那里以获取更新。
关于java - 使用@DataJpaTest 时未配置 JdbcTemplate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39264354/
应用程序上下文中的一些bean的依赖关系形成一个循环:当我使用时@Autowired私有(private) JdbcTemplate jdbcTemplate;不同类(class) 错误提示: ***
我做一个查询: jdbcTemplate.query(sqlQueryForGetNodes, new Object[]{treeId, versionId}, rs -> { NodeTy
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 3 年前。 Improve this ques
根据 Spring documentation ,Spring JdbcTemplate的使用步骤如下:
我做了这个简单的应用程序来连接到 MySQL 数据库,我收到了这个错误: org.springframework.jdbc.core.JdbcTemplate 在我的配置中 (com.kubamadr
我遵循了SpringBoot框架中的示例,该框架从这里开始,当我尝试添加Spring Bean时得到下一个错误。Pom.xml。我尝试插入到BD中,BD没有改变,应用程序本身可以工作,但没有连接数据库
我遵循了SpringBoot框架中的示例,该框架从这里开始,当我尝试添加Spring Bean时得到下一个错误。Pom.xml。我尝试插入到BD中,BD没有改变,应用程序本身可以工作,但没有连接数据库
我正在学习 Spring Boot 和 jdbcTemplate 的组合以进行一些基本的 crud 操作,并试图更好地理解我应该选择哪种更新方法。 我理解以下两种类方法(改编自 this post)将
如何使用行映射器向表中插入数据? 我正在尝试: Employee user1 = jtemplate.queryForObject("INSERT INTO employee(id, name,sal
我最近切换到 Spring Framework 而不是手动处理 JDBC,这主要是一个很好的过渡。但是,一个程序开始出现奇怪的问题:如果数据库速度很慢,则在调用 getJdbcTemplate().u
命令(Command)模式是指将请求封装成为一个对象,使发出请求和执行请求的责任分割开,方便将命令对象进行存储、传递、调用、增加与管理。 也就是将发送者、接收者和调用命令封装成独立的对象,来供客户端调
我有一个 spring 应用程序,它的主页会触发多个 ajax 调用,这些调用又从数据库中获取数据并返回。数据库已配置连接池,minPoolSize 为 50,maxPoolSize 为 100。 现
有人可以指出我以下 Spring Jdbc 模板代码中的任何错误吗? 当我点击删除时,记录没有被删除,也没有显示错误。 public void delete(String id) { logg
我正在使用 spring JDBCTemplate。 我有一个场景,其中需要传递到查询函数中的参数是条件/可选的。例如,我有以下代码: List result = jdbcTemplate.query
在项目中我在Hibernate和Spring jdbctemplate中是混合使用的。我添加了乐观锁定。 Hibernate 非常适合版本控制,但现在我必须转换所有这些 jdbctemplate 代码
我已经为我的INSERT查询建立了一个DAO。码: DAO public class EmployeeDao { JdbcTemplate template; public void
我有一个sql查询。 String sql = "SELECT ? FROM Users WHERE Lastname=?"; 我使用 JDBCTemplate 中的 queryForList 方法
我正在尝试将嵌套查询与 JdbcTemplate 一起使用,但发现了问题,在我看来,它不支持嵌套查询..我是对的吗?或者我需要改变什么? 所以,我调用 getJdbcTemplate().query
这个问题是几年前提出的,但答案对我来说不起作用。我已将建议的注释添加到配置和 dao 中。我确信模板实际上正在连接到数据库,因为当我的列太小时,我收到了适当的错误。更新调用正在执行单行插入,并且毫无异
JdbcTemplate 对象和 SimpleJdbcTemplate 之间有什么区别? 最佳答案 截至Spring 3.1 SimpleJdbcTemplate已弃用,SimpleJdbcTempl
我是一名优秀的程序员,十分优秀!