Mybatis-spring-boot - cant use datasource that was injected as bean

below is my configuration class.@Configuration@Componentclass Config {@Bean@ConfigurationProperties(prefix = "my.spring.datasource")public javax.sql.DataSource dataSource() { return

below is my configuration class.

@Configuration
@Component
class Config {
@Bean
@ConfigurationProperties(prefix = "my.spring.datasource")
public javax.sql.DataSource dataSource() {

    return DataSourceBuilder
            .create()
            .build();
}

}  

I am using Spring boot and spring-boot-mybatis-starter. My application.properties file is properly completed. Keep in mind, that I follow this: http://www.mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/

However, during launching I get error:

- Bean method 'dataSource' not loaded because @ConditionalOnProperty (spring.datasource.type) did not find property 'spring.datasource.type'
- Bean method 'dataSource' not loaded because @ConditionalOnProperty (spring.datasource.jndi-name) did not find property 'jndi-name'
- Bean method 'dataSource' not loaded because @ConditionalOnClass did not find required class 'javax.transaction.TransactionManager'   

Can you help me, please ?

When I excluce DataSourceAutoConfiguration then I get:

- Bean method 'dataSource' not loaded because @ConditionalOnProperty (spring.datasource.jndi-name) did not find property 'jndi-name'
- Bean method 'dataSource' not loaded because @ConditionalOnClass did not find required class 'javax.transaction.TransactionManager'  

When I drop datasource bean and remove prefix my. in all datasouece properties everything is ok.

Edit

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of method sqlSessionTemplate in org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration required a bean of type 'org.apache.ibatis.session.SqlSessionFactory' that could not be found.
    - Bean method 'sqlSessionFactory' in 'MybatisAutoConfiguration' not loaded because @ConditionalOnMissingBean (types: org.apache.ibatis.session.SqlSessionFactory; SearchStrategy: all) found bean 'sqlSessionFactory'


Action:

Consider revisiting the conditions above or defining a bean of type 'org.apache.ibatis.session.SqlSessionFactory' in your configuration.   

application.properties

my.spring.datasource.driverClassName=***
my.spring.datasource.url=****
my.spring.datasource.username=user
my.spring.datasource.password=****
my.spring.datasource.type=org.apache.tomcat.jdbc.pool.DataSource

make sure that you have configured the following properties in application.yml

spring:
  datasource:
    url: jdbc:oracle:thin:@db-host:port/catalog
    username: user
    password: pass
    driver-class-name: oracle.jdbc.OracleDriver

Once you do that, you will be able to inject DataSource to a sping component; as shown below.

@Autowired
DataSource dataSource;
Translating... 0%