Skip to content

Fully executable Jar does not scan typeAlias #38

Closed
@kazuki43zoo

Description

@kazuki43zoo

mybatis-spring-boot 1.0.1 does not scan typeAlias from specified package as follow:

mybatis.type-aliases-package=com.example.model

Specify a type alias in Mapper XML

<!DOCTYPE mapper PUBLIC
        "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.mapper.MessageMapper">
    <select id="findOne" resultType="Message"> <!-- ## Use type alias -->
        SELECT code, message FROM t_message WHERE code = #{code}
    </select>
</mapper>

Settings for building a fully executable jar

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <executable>true</executable> <!-- Add -->
            </configuration>
        </plugin>
    </plugins>
</build>

Build a fully executable jar

$ ./mvnw clean install

Run a fully executable jar

$ java -jar target/xxxx.jar
...
        at org.apache.ibatis.builder.xml.XMLMapperBuilder.configurationElement(XMLMapperBuilder.java:118)
        ... 44 more
Caused by: org.apache.ibatis.type.TypeException: Could not resolve type alias 'Message'.  Cause: java.lang.ClassNotFoundException: Cannot find class: Message
        at org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:120)
        at org.apache.ibatis.builder.BaseBuilder.resolveAlias(BaseBuilder.java:149)
        at org.apache.ibatis.builder.BaseBuilder.resolveClass(BaseBuilder.java:116)
        ... 48 more
...

Related issue : #35

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions