0

I have myBatis xml config SqlMapConfig.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>

    <!--<typeAliases>-->
        <!--<typeAlias alias = "class_alias_Name" type = "absolute_clas_Name"/>-->
    <!--</typeAliases>-->

    <environments default = "development">
        <environment id = "development">
            <transactionManager type = "JDBC"/>

            <dataSource type = "POOLED">
                <property name = "driver" value = "oracle.jdbc.driver.OracleDriver"/>
                <property name = "url" value = "jdbc:oracle:thin:@my_ip:port/dbname"/>
                <property name = "username" value = "username"/>
                <property name = "password" value = "password"/>
            </dataSource>

        </environment>
    </environments>

    <!--<mappers>-->
        <!--<mapper resource = "path of the configuration XML file"/>-->
    <!--</mappers>-->

</configuration>

I have dependency

<dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>1.1.1</version>
        </dependency>

I have Repository

@Mapper
public interface ImsiByMsisdnModelRepository {

    final String query = "....";

    @Select(query )
    @Results(value = {
            @Result(property = "msisdn", column = "MSISDN"),
            @Result(property = "terminalid", column = "TERMINALID"),
            @Result(property = "startDate", column = "START_DATE"),
            @Result(property = "endDate", column = "END_DATE"),
    })
    List<ImsiByMsisdnModel> getAll(@Param("msisdn") String msisdn);
}

But when I tried build priject I get error

Description:

Cannot determine embedded database driver class for database type NONE

Action:

If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active).

Hov can I setup SqlMapConfig.xml?

I tried write in application.properties line

mybatis.config-location=

but I do not know which path write. SqlMapConfig.xml placed in resources

user5620472
  • 2,722
  • 8
  • 44
  • 97
  • What are your other spring-boot dependencies ? Alo, please show us your complete application.properties – alexbt Nov 02 '16 at 09:51
  • I have the same issue, were you able to figure how to add the host? I have your same SqlMapConfig.xml, and in my application.properties I have: spring.datasource.schema=import.sql #mybatis.configuration=mybatis-config.xml mybatis.config-location=mybatis-config.xml logging.level.root=WARN logging.level.sample.mybatis.mapper=TRACE – Michael Lasso Nov 30 '16 at 18:52

2 Answers2

0

when you have dependency

<dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>1.1.1</version>
</dependency>

spring boot will auto config the spring jdbc and mybatis both.The only configuration it uses in spring jdbc is spring.datasource.*,you miss them,then the error you get(this error occur because auto config the spring jdbc failing).

so what you should do? add spring.datasource.*,so spring jdbc can be auto config successfully.

spring.database.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://host/table_name
spring.datasource.username=user
spring.datasource.password=password

then your mybatis will be auto config successfully.

facelessss
  • 37
  • 5
-1

I found that all you have to do is add the following to your application.properties file:

spring.database.driverClassName=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://host/table_name
spring.datasource.username=user
spring.datasource.password=password