5 Star 100 Fork 109

奇文社区 / ufop-spring-boot-starter

 / 详情

这个项目在单独启动时会报错

已完成
创建于  
2022-02-01 18:03

这个项目在单独启动时会报错


The bean 'fastDFSUploader', defined in class path resource [com/qiwenshare/ufop/autoconfiguration/UFOPAutoConfiguration.class], could not be registered. A bean with that name has already been defined in file [/Users/richard/IdeaProjects/ufop-spring-boot-starter/target/classes/com/qiwenshare/ufop/operation/upload/product/FastDFSUploader.class] and overriding is disabled.

重现步骤:

1.把ufop-spring-boot-starter项目拉到本地
2.com.qiwenshare.ufop包里创建App.java类

内容如下:

package com.qiwenshare.ufop;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class App {
    public static void main(String[] args) {
        SpringApplication.run(App.class, args);
    }
}

  1. 运行App.java

结果如下:

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

2022-02-01 18:02:20.983  INFO 60136 --- [           main] com.qiwenshare.ufop.App                  : Starting App using Java 1.8.0_261 on richards-MacBook-Pro.local with PID 60136 (/Users/richard/IdeaProjects/ufop-spring-boot-starter/target/classes started by richard in /Users/richard/IdeaProjects/ufop-spring-boot-starter)
2022-02-01 18:02:20.990  INFO 60136 --- [           main] com.qiwenshare.ufop.App                  : No active profile set, falling back to default profiles: default
2022-02-01 18:02:21.677  WARN 60136 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'fastDFSUploader' defined in class path resource [com/qiwenshare/ufop/autoconfiguration/UFOPAutoConfiguration.class]: Cannot register bean definition [Root bean: class [null]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=com.qiwenshare.ufop.autoconfiguration.UFOPAutoConfiguration; factoryMethodName=fastDFSUploader; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [com/qiwenshare/ufop/autoconfiguration/UFOPAutoConfiguration.class]] for bean 'fastDFSUploader': There is already [Generic bean: class [com.qiwenshare.ufop.operation.upload.product.FastDFSUploader]; scope=singleton; abstract=false; lazyInit=null; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=null; destroyMethodName=null; defined in file [/Users/richard/IdeaProjects/ufop-spring-boot-starter/target/classes/com/qiwenshare/ufop/operation/upload/product/FastDFSUploader.class]] bound.
2022-02-01 18:02:21.685  INFO 60136 --- [           main] ConditionEvaluationReportLoggingListener : 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-02-01 18:02:21.700 ERROR 60136 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'fastDFSUploader', defined in class path resource [com/qiwenshare/ufop/autoconfiguration/UFOPAutoConfiguration.class], could not be registered. A bean with that name has already been defined in file [/Users/richard/IdeaProjects/ufop-spring-boot-starter/target/classes/com/qiwenshare/ufop/operation/upload/product/FastDFSUploader.class] and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

Disconnected from the target VM, address: '127.0.0.1:62916', transport: 'socket'

评论 (5)

richardgong1987 创建了任务

这个问题,会造成依赖它的项目,打包后,都不能正常使用.

@MAC

这主要是由于重复配置造成的

该工程的使用方式是错误的,应该作为一个依赖引入到工程中,使用demo: UFOP使用参考代码

也可以参考该工程的readme文档

MAC 任务状态待办的 修改为已完成

登录 后才可以发表评论

状态
负责人
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
参与者(2)
947714 mac520 1578936443
Java
1
https://gitee.com/qiwen-cloud/ufop-spring-boot-starter.git
git@gitee.com:qiwen-cloud/ufop-spring-boot-starter.git
qiwen-cloud
ufop-spring-boot-starter
ufop-spring-boot-starter

搜索帮助