小编Fer*_*ubh的帖子

数据源的Spring Boot自动配置

我尝试使用Hibernate 5和Postgres 9创建Spring Boot应用程序.现在我有下一个错误:

Parameter 0 of constructor in org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration required a bean of type 'javax.sql.DataSource' that could not be found.
    - Bean method 'dataSource' not loaded because @ConditionalOnProperty (spring.datasource.jndi-name) did not find property 'jndi-name'
    - Bean method 'dataSource' not loaded because @ConditionalOnBean (types: org.springframework.boot.jta.XADataSourceWrapper; SearchStrategy: all) did not find any beans
Run Code Online (Sandbox Code Playgroud)

虽然,我添加了spring.datasource.*属性:

spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
spring.datasource.username=postgres
spring.datasource.password=root
Run Code Online (Sandbox Code Playgroud)

我的pom.xml:

<properties>
    <hibernate.version>5.2.6.Final</hibernate.version>
    <spring.data.version>1.10.6.RELEASE</spring.data.version>
</properties>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.3.RELEASE</version>
</parent>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-autoconfigure</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>${spring.version}</version>
    </dependency> …
Run Code Online (Sandbox Code Playgroud)

java hibernate maven spring-boot

26
推荐指数
2
解决办法
8万
查看次数

MyBatis"或"标准

我想用MyBatis创建一个查询,它将产生如下内容:

SELECT first_field, second_filed, third_field
WHERE first_field > 1 AND (second_field > 0 OR third_field < 0)
Run Code Online (Sandbox Code Playgroud)

我怎么能用Criteria对象构造它?

java mybatis

7
推荐指数
2
解决办法
1万
查看次数

Idea检查batis mapper bean错误

有Spring和MyBatis的网络项目.我使用IntelliJ IDEA进行开发.虽然存在与数据访问对象的链接,但IDEA无法正确检查MyBatis bean并产生令人讨厌的欠压.

检查评论:

 Could not autowire. No beans of 'ApplicationMapper' type found.
Run Code Online (Sandbox Code Playgroud)

我的Spring和MyBatis配置:Spring:

<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
    <property name="dataSource" ref="dataSource"/>
    <property name="configLocation" value="classpath:spring/mybatis-config.xml"/>

</bean>

<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
    <property name="basePackage" value="com.db.gbs.gbsapps.rds.backend.model.integration.mapping"/>
</bean>
Run Code Online (Sandbox Code Playgroud)

MyBatis的-config.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-config.dtd">

<configuration>
    <mappers>
        <mapper resource="mybatis/ApplicationMapper.xml"/>
    </mappers>
</configuration>
Run Code Online (Sandbox Code Playgroud)

有没有办法解决这个小问题?

java spring intellij-idea inspection mybatis

6
推荐指数
3
解决办法
8628
查看次数