Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

springboot中如果使用了@ImportResource注解,并且配置了*.xml直接导致通配符失效 #342

Open
strongant opened this issue Jun 21, 2024 · 1 comment

Comments

@strongant
Copy link

strongant commented Jun 21, 2024

使用的springboot 版本为2.7.13 , easeagent 版本为master 最新版本

比如原始代码如下:

@configuration
@ImportResource({ "classpath:spring/*.xml" })
public class DubboConfig {

}

当加入 easeagent之后,直接报错,找不到对应的Bean,影响正常启动。 报错为:

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.xxx.xxx.xxx.util.id.xxx' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotatio
ns: {@org.springframework.beans.factory.annotation.Qualifier(value="xxx")}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1801) ~[spring-beans-5.3.28.jar!/:5.3.28]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1357) ~[spring-beans-5.3.28.jar!/:5.3.28]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311) ~[spring-beans-5.3.28.jar!/:5.3.28]
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:887) ~[spring-beans-5.3.28.jar!/:5.3.28]
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:791) ~[spring-beans-5.3.28.jar!/:5.3.28]
... 27 more

如果调整为如下方式则可以正常启动:

@Configuration
@ImportResource({"classpath:spring/spring-benas.xml"})
public class DubboConfig {

}
@strongant
Copy link
Author

strongant commented Jun 21, 2024

将easeagentt的jar 放到启动命令的最后即可避免该问题发生,比如:java -jar xxx.jar -javaagent:/Users/apple/wingate-agent/wingate-agent.jar

主要原因为:因此导致冲突产生,具体产生问题的root cause 代码为:

org.springframework.core.io.support.PathMatchingResourcePatternResolver#findPathMatchingResources
...
URL rootDirUrl = rootDirResource.getURL(); 
...

@strongant strongant reopened this Jun 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant