Когда я обновился до Spring v6.1 с версии 6.0, при запуске проекта я столкнулся со следующей ошибкой. В Spring v6.0 все работает хорошо.
[ERROR] 2024-06-29 07:41:58,242 [main] org.springframework.web.context.ContextLoader - Context initialization failed
java.lang.IllegalArgumentException: Invalid value type for attribute 'factoryBeanObjectType': java.lang.String
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getTypeForFactoryBeanFromAttributes(FactoryBeanRegistrySupport.java:86) ~[spring-beans-6.1.10.jar:6.1.10]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryBean(AbstractAutowireCapableBeanFactory.java:837) ~[spring-beans-6.1.10.jar:6.1.10]
at org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(AbstractBeanFactory.java:663) ~[spring-beans-6.1.10.jar:6.1.10]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:575) ~[spring-beans-6.1.10.jar:6.1.10]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:534) ~[spring-beans-6.1.10.jar:6.1.10]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:138) ~[spring-context-6.1.10.jar:6.1.10]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:788) ~[spring-context-6.1.10.jar:6.1.10]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:606) ~[spring-context-6.1.10.jar:6.1.10]
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:394) ~[spring-web-6.1.10.jar:6.1.10]
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:274) [spring-web-6.1.10.jar:6.1.10]
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:102) [spring-web-6.1.10.jar:6.1.10]
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3997) [catalina.jar:10.1.25]
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4424) [catalina.jar:10.1.25]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164) [catalina.jar:10.1.25]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:599) [catalina.jar:10.1.25]
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:571) [catalina.jar:10.1.25]
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:654) [catalina.jar:10.1.25]
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1130) [catalina.jar:10.1.25]
at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1933) [catalina.jar:10.1.25]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) [?:?]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) [tomcat-util.jar:10.1.25]
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:123) [?:?]
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1041) [catalina.jar:10.1.25]
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:425) [catalina.jar:10.1.25]
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1629) [catalina.jar:10.1.25]
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:303) [catalina.jar:10.1.25]
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:109) [catalina.jar:10.1.25]
at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:385) [catalina.jar:10.1.25]
at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:332) [catalina.jar:10.1.25]
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:776) [catalina.jar:10.1.25]
at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:772) [catalina.jar:10.1.25]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164) [catalina.jar:10.1.25]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1203) [catalina.jar:10.1.25]
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1193) [catalina.jar:10.1.25]
at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75) [tomcat-util.jar:10.1.25]
at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145) [?:?]
at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:749) [catalina.jar:10.1.25]
at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:203) [catalina.jar:10.1.25]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164) [catalina.jar:10.1.25]
at org.apache.catalina.core.StandardService.startInternal(StandardService.java:415) [catalina.jar:10.1.25]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164) [catalina.jar:10.1.25]
at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:874) [catalina.jar:10.1.25]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164) [catalina.jar:10.1.25]
at org.apache.catalina.startup.Catalina.start(Catalina.java:757) [catalina.jar:10.1.25]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:345) [bootstrap.jar:10.1.25]
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:473) [bootstrap.jar:10.1.25]
Чтобы воспроизвести проект с минимальной настройкой, вы можете использовать следующие команды в проекте voj.
Пожалуйста, убедитесь, что у вас установлены g++
, java
и maven
.
git clone https://github.com/hzxie/voj
cd voj/judger
# The error can be reproduced in this commit.
git reset 9726a05 --hard
mvn package -DskipTests
java -jar target/voj.judger.jar
Обновление mybatis-spring
JAR до версии 3.0.3
решает эту проблему. Конфигурация зависимостей в pom.xml
представлена ниже.
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>3.0.3</version>
</dependency>