光辉飞翔

导航

 

Attributes should be specified via @SpringBootApplication

刘超 1年前 ⋅ 4051 阅读   编辑
 

一、描述

  设置EnableAutoConfiguration,如下

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication
@EnableAutoConfiguration(exclude = {org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration.class})
@EnableScheduling
public class DQServerApplication {

    public static void main(String[] args) {
        System.setProperty("mail.mime.splitlongparameters", "false");
        SpringApplication.run(DQServerApplication.class, args);
    }

}

  在idea中报如下错误

  

二、分析

  查看代码发现,SpringBootApplication中已经包含EnableAutoConfiguration,不需要重复定义

三、解决方法

  去掉EnableAutoConfiguration即可,如下

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;

@SpringBootApplication(exclude = {org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration.class})
@EnableScheduling
public class DQServerApplication {

    public static void main(String[] args) {
        System.setProperty("mail.mime.splitlongparameters", "false");
        SpringApplication.run(DQServerApplication.class, args);
    }

}
posted on 2021-03-08 15:30  光辉飞翔  阅读(2649)  评论(0编辑  收藏  举报