Error starting ApplicationContext.错误解决

启动springboot项目报错: Error starting ApplicationContext. To display the auto-configuration report re-run your application with ‘debug’ enabled.

问题描述:

启动springboot项目报错: Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled
在我的项目中,控制台下面还给出提示:

Description:
Parameter 0 of method upload in com.comtop.pmmicro.attactmentUpload.controller.AttachmentUploadController required a bean of type 'org.springframework.web.multipart.MultipartFile' that could not be found.
Action:
Consider defining a bean of type 'org.springframework.web.multipart.MultipartFile' in your configuration.

因为我用到了MultipartFile,所以这里是org.springframework.web.multipart.MultipartFile,你用其他类可能就是你用到的类。*

解决问题:

我在类中用到了@Autowired,引入了import org.springframework.beans.factory.annotation.Autowired,去掉导入的这个包后,解决了问题。

问题总结:

我在网上搜到的解决这种问题的方法有以下几种:
1.启动类的@EnableAutoConfiguration@SpringBootApplication中添加(exclude = {DataSourceAutoConfiguration.class})或者(exclude ={DataSourceAutoConfiguration.class,HibernateJpaAutoConfiguration.class}),排除此类的autoconfig
2.去掉导入的包:import org.springframework.*.annotation.*
3.如果是springmvc项目,需要在配置文件中配置MultipartFile

你可能感兴趣的:(springboot)