Tag Archives: web.xml

[Solved]Org.springframework.beans.factory.nosuchbeandefinitionexception error reported

Problems:
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘com.pri.dao.UserDao’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
Problem Description:
No match to com.pri.dao.UserDao
Error code:

14-Aug-2021 09:57:18.405 Warning [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log No Spring WebApplicationInitializer types detected on classpath
14-Aug-2021 09:57:18.445 Warning [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log Initializing Spring root WebApplicationContext
14-Aug-2021 09:57:20.787 Warning [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
 org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userController': Unsatisfied dependency expressed through field 'userService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userServiceImpl': Unsatisfied dependency expressed through field 'userDao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.pri.dao.UserDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:130)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1420)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551)
	at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:401)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:292)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:103)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4861)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5322)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)
	at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:753)
	at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:729)
	at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:717)
	at org.apache.catalina.startup.HostConfig.manageApp(HostConfig.java:1730)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:484)
	at org.apache.catalina.mbeans.MBeanFactory.createStandardContext(MBeanFactory.java:433)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.apache.tomcat.util.modeler.BaseModelMBean.invoke(BaseModelMBean.java:300)
	at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke(DefaultMBeanServerInterceptor.java:819)
	at com.sun.jmx.mbeanserver.JmxMBeanServer.invoke(JmxMBeanServer.java:801)
	at com.sun.jmx.remote.security.MBeanServerAccessController.invoke(MBeanServerAccessController.java:468)
	at javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1468)
	at javax.management.remote.rmi.RMIConnectionImpl.access$300(RMIConnectionImpl.java:76)
	at javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1309)
	at java.security.AccessController.doPrivileged(Native Method)
	at javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1408)
	at javax.management.remote.rmi.RMIConnectionImpl.invoke(RMIConnectionImpl.java:829)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:324)
	at sun.rmi.transport.Transport$1.run(Transport.java:200)
	at sun.rmi.transport.Transport$1.run(Transport.java:197)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
	at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:568)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:826)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:683)
	at java.security.AccessController.doPrivileged(Native Method)
	at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:682)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userServiceImpl': Unsatisfied dependency expressed through field 'userDao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.pri.dao.UserDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:130)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1420)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1307)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1227)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
	... 62 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.pri.dao.UserDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1717)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1273)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1227)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
	... 75 more

14-Aug-2021 09:57:20.797 信息 [RMI TCP Connection(3)-127.0.0.1] org.apache.catalina.core.ApplicationContext.log Closing Spring root WebApplicationContext

Solution:
first, check whether the Dao layer (mapper layer) has the annotation @ repository. Only when this annotation is added can this class be loaded during spring initialization.
Second, check whether the annotation is scanned in the spring configuration file. Note that the mappercannerconfigurer should be used to scan the interface of Dao layer

<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.pri.dao"></property>
</bean>

instead of

<context:component-scan base-package="com.pri.dao"></context:component-scan>

This tag scans the basic components and the other three components @service @component @controller
the author made this mistake and found it after looking for a long time
so we must pay attention to the details and pay attention to the details
If an error is reported, you should analyze it yourself first. For example, if you can’t find the corresponding userdao and have comments on this class, you can only analyze the problem in the spring.xml configuration file and the scanning package
I hope I can help you!!!

web.xml Solution of < async supported > true < / async supported > error in configuration file

I’m writing web.xml I always reported cvc-complex-type. 2.4. A: invalid content was found starting with element error again. I also found a small red cross. I found a lot of Red Cross on the Internet. It was said that I wrote the code of red cross between & lt; JSP config & gt; & lt; & JSP config & gt;, but it was useless after trying. Then I found a solution to the problem on the foreign language website

Solution 1:
configure XML in eclipse
1 http://www.springmodules.org/schema/cache/springmodules-cache.xsd
   2、 http://www.springmodules.org/schema/cache/springmodules-ehcache.xsd
and then add these two xsds to the web.xml The code is as follows:

web.xml code

    <?xml version=”1.0″ encoding=”UTF-8″?>   < web-app version=”2.4″ xmlns=” http://java.sun.com/xml/ns/j2ee ”        xmlns:xsi= ” http://www.w3.org/2001/XMLSchema-instance    http://www.springmodules.org/schema/cache/springmodules-cache.xsd   http://www.springmodules.org/schema/cache/springmodules-ehcache.xsd ”     xsi:schemaLocation= ” http://java.sun.com/xml/ns/j2ee    http://java.sun.com/xml/ns/j2ee/web-app_ 2_ 4.xsd”>       <!–OS Work Flow –>       <display-name>OSWorkflow Example App</display-name>       <description>OSWorkflow Example App</description>                <servlet>           <servlet-name>SOAPWorkflow</servlet-name>           < servlet-class>                com.opensymphony.workflow . soap.SOAPWorkflowServlet            </servlet-class>       </servlet>       <servlet>           <description>               This is the description of my J2EE component           < /description>           <display-name>               This is the display name of my J2EE component           </display-name>           <servlet-name>Osworkflow</servlet-name>           <servlet-class> net.caiban.servlet .Osworkflow</servlet-class>        </servlet>       <servlet>           <description>               This is the description of my J2EE component           </description>           <display-name>                This is the display name of my J2EE component           </display-name>           <servlet-name>DoWorkflow</servlet-name>           <servlet-class> net.caiban.servlet .DoWorkflow</servlet-class>       </servlet>       <servlet>            <description>               This is the description of my J2EE component           </description>           <display-name>               This is the display name of my J2EE component           </display-name>            <servlet-name>CreateWorkflow</servlet-name>           <servlet-class> net.caiban.servlet .CreateWorkflow</servlet-class>       </servlet>                   <servlet-mapping>           <servlet-name>SOAPWorkflow</servlet-name>            <url-pattern>/soap/*</url-pattern>       </servlet-mapping>          <servlet-mapping>           <servlet-name>Osworkflow</servlet-name>           <url-pattern>/servlet/Osworkflow</url-pattern>       </servlet-mapping>        <servlet-mapping>           <servlet-name>DoWorkflow</servlet-name>           <url-pattern>/servlet/DoWorkflow</url-pattern>       </servlet-mapping>       <servlet-mapping>           <servlet-name>CreateWorkflow</servlet-name>            <url-pattern>/servlet/CreateWorkflow</url-pattern>       </servlet-mapping>          <welcome-file-list>           <welcome-file> default.jsp&lt ;/welcome-file>           <welcome-file> index.jsp&lt ;/welcome-file>       </welcome-file-list>        <resource-ref>           <res-ref-name>jdbc/oswf</res-ref-name>           <res-type> javax.sql.DataSource&lt ;/res-type>           <init-param driverClassName=” com.mysql.jdbc .Driver” />           <init-param url=” jdbc:mysql :// localhost:3306/osworkflow ” />            <init-param user=”root” />           <init-param password=”123465″ />           <init-param max-connections=”20″ />           <init-param max-idle-time=”30″ />       </resource-ref>       <!–OS Work Flow –>   </web-app>  

Solution 2:

≪ async supported & gt; true & lt;/async supported & gt; yes web.xml 3.0, just add

<web-app xmlns:xsi= ” http://www.w3.org/2001/XMLSchema-instance ” xmlns=” http://Java.sun.com/xml/ns/javaee ” xsi:schemaLocation= ” http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_ 2_ 5.xsd” id=”WebApp_ ID” version=”2.5″>

Change to:

<web-app xmlns:xsi= ” http://www.w3.org/2001/XMLSchema-instance ” xmlns=” http://java.sun.com/xml/ns/javaee ” xsi:schemaLocation= ” http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_ 3_ 0.xsd” id=”WebApp_ ID” version=”3.0″>

It can be solved.

Original address: http://blog.csdn.net/zxz547388910/article/details/50780068