spring-projects / spring-boot

Spring Boot
https://spring.io/projects/spring-boot
Apache License 2.0
74.73k stars 40.58k forks source link

Spring Boot with MyBatis - AnnotationFormatError #14917

Closed fengbin8606 closed 5 years ago

fengbin8606 commented 5 years ago

My pom.xml is:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.promotion</groupId>
    <artifactId>PromotionMonitor</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>  

    <name>PromotionMonitor</name>
    <description>Demo project for Spring Boot</description>

    <parent> 
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.6.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

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

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

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

        <dependency>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>1.11.2</version>
        </dependency>

        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
        </dependency>

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

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
        </dependency>

        <dependency>     
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.14.0</version>
        </dependency>

        <dependency>
            <groupId>net.sourceforge.htmlunit</groupId>
            <artifactId>htmlunit</artifactId>
            <version>2.32</version>
        </dependency>

        <dependency>
            <groupId>com.googlecode.json-simple</groupId>
            <artifactId>json-simple</artifactId>
            <version>1.1.1</version>
        </dependency>

        <dependency>
            <groupId>com.xiaomi.mipush.sdk</groupId>
            <artifactId>mipush</artifactId>
            <version>2.2.19</version>
        </dependency>

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

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>      
        <resources>         
            <resource>  
                <directory>src/main/java</directory>  
                <includes>  
                    <include>**/*.xml</include>  
                </includes>  
                <filtering>false</filtering>  
            </resource>        
            <resource>  
                <directory>src/main/resources</directory>  
                <includes>  
                    <include>*.properties</include>
                    <include>*.xml</include>
                </includes>  
                <filtering>false</filtering>  
            </resource>   
        </resources>   
    </build>
</project>

And the error message is:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.0.6.RELEASE)

2018-10-22 09:59:43,493 INFO  8712 [           main]  c.promotion.PromotionMonitorApplication  : Starting PromotionMonitorApplication on ZDRJ-FENGBIN with PID 8712 (D:\PromotionMonitor\PromotionMonitor\target\classes started by fengbin in D:\PromotionMonitor\PromotionMonitor)
2018-10-22 09:59:43,499 INFO  8712 [           main]  c.promotion.PromotionMonitorApplication  : No active profile set, falling back to default profiles: default
2018-10-22 09:59:43,520 INFO  8712 [           main]  o.s.core.annotation.AnnotationUtils      : Failed to introspect annotations on class com.promotion.PromotionMonitorApplication: java.lang.annotation.AnnotationFormatError: Invalid default: public abstract java.lang.Class org.mybatis.spring.annotation.MapperScan.factoryBean()
2018-10-22 09:59:43,859 ERROR 8712 [           main]  o.s.boot.SpringApplication               : Application run failed
java.lang.annotation.AnnotationFormatError: Invalid default: public abstract java.lang.Class org.mybatis.spring.annotation.MapperScan.factoryBean()
    at java.lang.reflect.Method.getDefaultValue(Unknown Source)
    at sun.reflect.annotation.AnnotationType.<init>(Unknown Source)
    at sun.reflect.annotation.AnnotationType.getInstance(Unknown Source)
    at sun.reflect.annotation.AnnotationParser.parseAnnotation2(Unknown Source)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations2(Unknown Source)
    at sun.reflect.annotation.AnnotationParser.parseAnnotations(Unknown Source)
    at java.lang.Class.createAnnotationData(Unknown Source)
    at java.lang.Class.annotationData(Unknown Source)
    at java.lang.Class.getAnnotations(Unknown Source)
    at org.springframework.core.type.StandardAnnotationMetadata.<init>(StandardAnnotationMetadata.java:70)
    at org.springframework.beans.factory.annotation.AnnotatedGenericBeanDefinition.<init>(AnnotatedGenericBeanDefinition.java:58)
    at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.doRegisterBean(AnnotatedBeanDefinitionReader.java:216)
    at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.registerBean(AnnotatedBeanDefinitionReader.java:145)
    at org.springframework.context.annotation.AnnotatedBeanDefinitionReader.register(AnnotatedBeanDefinitionReader.java:135)
    at org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:158)
    at org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:135)
    at org.springframework.boot.BeanDefinitionLoader.load(BeanDefinitionLoader.java:127)
    at org.springframework.boot.SpringApplication.load(SpringApplication.java:696)
    at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:381)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:305)
    at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:137)
    at com.promotion.PromotionMonitorApplication.main(PromotionMonitorApplication.java:24)

I think there is something wrong between then: Spring Boot 2.0.6.RELEASE mybatis-spring-boot-starter 1.3.2

mbhave commented 5 years ago

The 1.3.2 version of the mybatis starter looks like it's based off Spring Boot 1.5.x. It doesn't look like they have a release compatible with Spring Boot 2.0. In any case, this seems like a question for the mybatis team than a Spring Boot issue.

snicoll commented 5 years ago

@fengbin8606 the team working on the starter believes 1.3.x works with Spring Boot 2. If that's not the case, please open an issue in their issue tracker

kazuki43zoo commented 5 years ago

@fengbin8606 Could you create a new issue on mybatis-spring-boot and provide a reproduce small project via GitHub?