pf4j-spring
pf4j-spring copied to clipboard
Trying to run the Spring demo-app but got error creating bean with name 'greetings
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'greetings': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.util.List org.pf4j.demo.Greetings.greetings; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.pf4j.demo.api.Greeting] found for dependency [collection of org.pf4j.demo.api.Greeting]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.context.annotation.AnnotationConfigApplicationContext.<init>(AnnotationConfigApplicationContext.java:84)
at org.pf4j.demo.Boot.main(Boot.java:35)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private java.util.List org.pf4j.demo.Greetings.greetings; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.pf4j.demo.api.Greeting] found for dependency [collection of org.pf4j.demo.api.Greeting]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:508)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:289)
... 12 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.pf4j.demo.api.Greeting] found for dependency [collection of org.pf4j.demo.api.Greeting]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1103)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:915)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:858)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:480)
... 14 more
I ported run-demo
scripts from pf4j to pf4j-spring project.
Can you run demo script from command line (run-demo.sh
for linux or run-demo.bat
for windows) and share the result?
@muyen Any news? Did you solve the problem?
yeah, it is working with run-demo.sh. However, the plugin jars are not copied from target to demo/plugins. In the run-demo.sh, it should be "cp demo/plugins/*/target/plugin.jar demo-dist/plugins/"
@muyen
If you can run demo without any problem, via run-demo.sh
, I don't understand where is the problem.
I don't see the exception when I use run-demo.sh. However, run-demo.sh loads only the org.pf4j.demo.WhazzupGreeting plugin and not the plugin1 and plugin2. The plugins jars are not copied to the target folder. It should be
cp demo/plugins/*/target/plugin*.jar demo-dist/plugins/
Because the plugins name is pf4j-spring-demo-plugin1-0.6.0-SNAPSHOT.jar
I concur. I found the same problem with run-demo.sh. I don't see how your pattern will work either, as the jar file names don't start with 'plugin'. I changed the script to just copy all jars, since there's only one in each directory:
cp demo/plugins/*/target/*.jar demo-dist/plugins/
and the demo then runs all three plugins.
You should add an extensions.idx file into both plugin sources to run the demo in development mode
without to launch run-demo.sh/bat
, is it true?
hi how do i fix this?