i add spring boot project as dependency in spring mvc project , application can run successfully but when i call service i faced below error
Context initialization failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed
to read candidate component class: nested exception is
org.springframework.core.annotation.AnnotationConfigurationException:
Attribute 'proxyBeanMethods' in annotation
[org.springframework.boot.SpringBootConfiguration] is declared as an
#AliasFor nonexistent attribute 'proxyBeanMethods' in annotation
[org.springframework.context.annotation.Configuration].; nested
exception is java.lang.NoSuchMethodException:
org.springframework.context.annotation.Configuration.proxyBeanMethods()
Attribute 'proxyBeanMethods' in annotation
[org.springframework.boot.SpringBootConfiguration] is declared as an
#AliasFor nonexistent attribute 'proxyBeanMethods' in annotation
[org.springframework.context.annotation.Configuration].; nested
exception is java.lang.NoSuchMethodException:
org.springframework.context.annotation.Configuration.proxyBeanMethods()
It mainly complains about your #Configuration does not have an attribute called proxyBeanMethods. Checking from the javadoc , this attribute is added since Spring 5.2.
Most probably it is because you are messing up the spring version with your spring-boot version. Your spring version is too old (before 5.2) such that the above attribute of the #Configuration is not defined.
You should use the spring framework which the version is defined by the spring-boot version that you use . Show me the pom.xml and I can help to check which <dependency> causes such version mismatch. Thanks.
Related
Good day,
I am doing a Spring Boot Application in my Eclipse IDE. When I right click on my SpringBoot Application file and run as Java application, I hitting error as follow:
APPLICATION FAILED TO START
Description:
Field tutorialRepository in com.utility.tool.ToolApplication required a bean of type 'com.utility.tool.repository.TutorialRepository' that could not be found.
The injection point has the following annotations:
- #org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type 'com.utility.tool.repository.TutorialRepository' in your configuration.
Then I found that I forget to include the spring boot starter data jar. Hence, I add the following code in my build.gradle and it finally run correctly:
implementation 'org.springframework.boot:spring-boot-starter-data-jpa:2.7.5'
Then I right click my project and export jar as runnable jar, and then try to run it by java -jar my.jar, and it hit back the error.
I open the jar in JdGui, and found that the spring-boot-starter-data-jpa-2.7.5.jar is inside. May I know what is my mistake? My jar structure is something as follow:
The jar is in the list but is at bottom, thus not in my screen shot.
Check your SpringBoot annotations. You may be missing some #Service, #Repository, #Component annotations.
When I run spring boot I get the following error. I have replaced sensitive parts with '...' as the problem should be clear anyway. This error happened without me changing any of the code in the class that is causing the error.
Description:
The bean '...', defined in class path resource [....class], could not
be registered. A bean with that name has already been defined in URL
[jar:file:/C:/m2/repository/.../0-SNAPSHOT/...-0-SNAPSHOT.jar!/...class]
and overriding is disabled.
Action:
Consider renaming one of the beans or enabling overriding by setting
spring.main.allow-bean-definition-overriding=true
After upgrading my project to Spring AOP 4.3.7 I get this error trace on every bean auto-wire at Spring Boot startup:
Caused by: java.lang.NoSuchMethodError: org.springframework.aop.framework.AopProxyUtils.getSingletonTarget(Ljava/lang/Object;)Ljava/lang/Object;
at org.springframework.context.event.AbstractApplicationEventMulticaster.addApplicationListener(AbstractApplicationEventMulticaster.java:105)
at org.springframework.context.support.AbstractApplicationContext.addApplicationListener(AbstractApplicationContext.java:494)
at org.springframework.context.support.ApplicationListenerDetector.postProcessAfterInitialization(ApplicationListenerDetector.java:78)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:423)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1633)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555)
...Stack truncated here for privacy reasons...
I get the sense this is a mismatch in a Spring AOP Jar somewhere in the stack, but cannot find anything that references an actual object to trace.
I was able to resolve this by upgrading to Spring AOP 4.3.13
See these links for the old and new versions of these libraries in the API.
I have an application with one Spring #Controller annotated with #RequestMapping.
Using Spring (core and webmvc) 4.1.0.RELEASE or higher I'm getting exception when starting the app server.
java.lang.NoSuchMethodError: org.springframework.web.bind.annotation.RequestMapping.name()Ljava/lang/String;
at method RequestMappingHandlerMapping.createRequestMappingInfo(RequestMapping annotation, RequestCondition<?> customCondition)
Debugging, using Eclipse inspect, the method variable annotation does not contains name attribute and fails at action annotation.name(). All the other attributes values are correct (they have the values defined in the Controller method annotated with #RequestMapping).
I'm using Tomcat 7 and Maven 2.3.
mvn dependency:tree does not shows other Spring version than 4.1.0.RELEASE.
The error does not occurs when using Spring 4.0.7.RELEASE or lower.
Does anyone have any clue?
Seems like a classpath issue. An old version of RequestMapping was being loaded.
I'm having the following issue with my hibernate 3.6.10 project:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'testSessionFactory' defined in class path resource [db.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: javax.persistence.OneToMany.orphanRemoval()Z
Reading some of the issues here on stack overflow, it said I was using the wrong persistence API. So I downloaded the matching hibernate (I've been using the Spring deployment) and copied out the hibernate-jpa-2.0-api-1.0.1.Final.jar which comes with the hibernate distrib, only to get the self-same message.
Is this telling me that OneToMany is not supported by Hibernate 3.6.10?
It tells your that you have a JPA 1.0 API jar somewhere in your classpath. Such a problem cannot be reliably solved by adding proper JPA 2.0 jar to the classpath, you need to find and remove the offending jar before.