question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fully executable Jar does not scan typeAlias

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:19 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
TracyBincommented, Nov 3, 2017

@kazuki43zoo , Yes,the problem is solved.Thanks for your reply.

0reactions
kazuki43zoocommented, May 29, 2018

If you need my help, I want to a small reproduce project(maven or gradle). It is difficult to analyze issue with stack trace only in this case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

mybatis-spring & spring boot - Could not resolve type alias issue
My situation is that I have a executable jar with Spring Boot which has a nested jar (which uses regular Spring) as dependency....
Read more >
MyBatis 3 | Configuration
Specifies if and how MyBatis should automatically map columns to fields/properties. NONE disables auto-mapping. PARTIAL will only auto-map ...
Read more >
The Executable Jar Format - Spring
A shaded jar packages all classes, from all jars, into a single “uber jar”. The problem with shaded jars is that it becomes...
Read more >
com.baomidou.mybatisplus.extension.spring ... - Download JAR files
typeAliases = typeAliases; } /** * If true, a final check is done on Configuration to assure that all mapped * statements are...
Read more >
intellij 나 STS에서 실행하면 아무 문제 없는데 executable jar로 ...
TypeException: Could not resolve type alias "entities". 이런 오류가 나네요. ... Fully executable Jar does not scan typeAlias · Issue #38 · mybatis/spring-....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found