MAVEN cannot compile a solution to the XML file below Src/main/java

Source: Internet
Author: User
Tags addchild
The reason for the error:

Maven was unable to compile and package the XML file below Src/main/java when the project was packaged and published using MAVEN
Directory structure: Banklogmapper.xml under Mapper package for this project cannot compile package
Solution One:

1. So you must add the following code in the Pom.xml file

    <build> ...
        <resources> ...
            <!--specify XML file location-->
            <resource>
                <directory>src/main/java</directory>
                < includes>
                    <include>**/*.xml</include>
                </includes>
                <filtering>true </filtering>
            </resource>
        </resources>
    </build>
Solution Two:

2. In the design of the project structure, put all the configuration files in the resources to manage
Directory structure:
Error code:

Org.springframework.beans.factory.BeanCreationException:Error creating bean with Name ' Org.mybatis.spring.mapper.mapperscannerconfigurer#0 ' defined in class path resource [Config/applicationcontext.xml]: Cannot resolve reference to the bean ' sqlsessionfactory ' while the setting bean property ' sqlsessionfactory '; Nested exception is org.springframework.beans.factory.BeanCreationException:Error creating beans with Name ' Sqlsessionfactory ' defined in class path resource [Config/applicationcontext.xml]: Initialization of Bean failed; Nested exception is org.springframework.beans.TypeMismatchException:Failed to convert property value of type ' Java.lang. String ' to required type ' org.springframework.core.io.resource[] ' for property ' mapperlocations '; Nested exception is java.lang.IllegalArgumentException:Could not resolve resource location pattern [classpath:com/cp/
    Bank/mapper/xml/*.xml]: Class path resource [com/cp/bank/mapper/xml/] cannot is resolved to URL because it does not exist At Org.sPringframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference ( beandefinitionvalueresolver.java:359) at Org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary ( beandefinitionvalueresolver.java:108) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues ( abstractautowirecapablebeanfactory.java:1469) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean ( abstractautowirecapablebeanfactory.java:1214) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean ( abstractautowirecapablebeanfactory.java:537) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean ( abstractautowirecapablebeanfactory.java:476) at org.springframework.beans.factory.support.abstractbeanfactory$1. GetObject (abstractbeanfactory.java:302) at Org.springframework.beans.factory.support.DefaulTsingletonbeanregistry.getsingleton (defaultsingletonbeanregistry.java:230) at Org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (abstractbeanfactory.java:298) at Org.springframework.beans.factory.support.AbstractBeanFactory.getBean (abstractbeanfactory.java:198) at Org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors ( postprocessorregistrationdelegate.java:116) at Org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors ( abstractapplicationcontext.java:606) at Org.springframework.context.support.AbstractApplicationContext.refresh ( abstractapplicationcontext.java:462) at
    Org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext (contextloader.java:403) At Org.springframework.web.context.ContextLoader.initWebApplicationContext (contextloader.java:306) at Org.springframework.web.context.ContextLoaderListener.contextInitialized (Contextloaderlistener.java:106) at Org.apache.catalina.core.StandardContext.listenerStart (Standardcontext.java : 4939) at Org.apache.catalina.core.StandardContext.startInternal (standardcontext.java:5434) at Org.apache.catalina . util. Lifecyclebase.start (lifecyclebase.java:150) at Org.apache.catalina.core.ContainerBase.addChildInternal ( containerbase.java:901) at Org.apache.catalina.core.ContainerBase.addChild (containerbase.java:877) at org.apache.c Atalina.core.StandardHost.addChild (standardhost.java:633) at ORG.APACHE.CATALINA.STARTUP.HOSTCONFIG.MANAGEAPP ( hostconfig.java:1551 in Sun.reflect.NativeMethodAccessorImpl.invoke0 (Native method) at Sun.reflect.NativeMethodAc Cessorimpl.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.uti L.modeler.basemodelmbean.invoke (basemodelmbean.java:301) 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:622) at Org.apache.catalina.mbeans.MBeanFactory.createStandardContext (mbeanfactory.java:569) 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.uti L.modeler.basemodelmbean.invoke (basemodelmbean.java:301) at Com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.invoke (defaultmbeanserverinterceptor.java:819) at Com.sun.jmx.mbeanserver.JmxMBeanServer.invoke (jmxmbeanserver.java:801) at Javax.management.remote.rmi.RMIConnectionImpl.doOperation (Rmiconnectionimpl.java:1468) at javax.management.remote.rmi.rmiconnectionimpl.access$300 (RMIConnectionImpl.java : In Javax.management.remote.rmi.rmiconnectionimpl$privilegedoperation.run (rmiconnectionimpl.java:1309) at Java X.management.remote.rmi.rmiconnectionimpl.doprivilegedoperation (rmiconnectionimpl.java:1401) 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.Unicas Tserverref.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.BeanCreationException:Error Creating bean with Name ' sqlsessionfactory ' defined in class path resource [Config/applicationcontext.xml]: Initializatio N of Bean failed; Nested exception is org.springframework.beans.TypeMismatchException:Failed to convert property value OF type ' java.lang.String ' to required type ' org.springframework.core.io.resource[] ' for property ' mapperlocations '; Nested exception is java.lang.IllegalArgumentException:Could not resolve resource location pattern [classpath:com/cp/
    Bank/mapper/xml/*.xml]: Class path resource [com/cp/bank/mapper/xml/] cannot is resolved to URL because it does not exist At Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean ( abstractautowirecapablebeanfactory.java:547) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean ( abstractautowirecapablebeanfactory.java:476) at org.springframework.beans.factory.support.abstractbeanfactory$1. GetObject (abstractbeanfactory.java:302) at Org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton ( defaultsingletonbeanregistry.java:230) at Org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (abstractbeanfactory.java:298) at Org.sPringframework.beans.factory.support.AbstractBeanFactory.getBean (abstractbeanfactory.java:193) at Org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference ( beandefinitionvalueresolver.java:351) ... caused By:org.springframework.beans.TypeMismatchException:Failed to convert property value of type ' java.lang.St Ring ' to required type ' org.springframework.core.io.resource[] ' for property ' mapperlocations '; Nested exception is java.lang.IllegalArgumentException:Could not resolve resource location pattern [classpath:com/cp/
    Bank/mapper/xml/*.xml]: Class path resource [com/cp/bank/mapper/xml/] cannot is resolved to URL because it does not exist At Org.springframework.beans.BeanWrapperImpl.convertIfNecessary (beanwrapperimpl.java:480) at Org.springframework. Beans. Beanwrapperimpl.convertforproperty (beanwrapperimpl.java:511) at Org.springframework.beans.BeanWrapperImpl.convertForProperty (beanwrapperimpl.java:505) at Org.springframeworK.beans.factory.support.abstractautowirecapablebeanfactory.convertforproperty ( abstractautowirecapablebeanfactory.java:1515) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues ( abstractautowirecapablebeanfactory.java:1474) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean ( abstractautowirecapablebeanfactory.java:1214) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean ( abstractautowirecapablebeanfactory.java:537) ... By:java.lang.IllegalArgumentException:Could caused resolve resource location pattern [Classpath:com/cp/bank
    /mapper/xml/*.xml]: Class path resource [com/cp/bank/mapper/xml/] cannot is resolved to URL because it does not exist At Org.springframework.core.io.support.ResourceArrayPropertyEditor.setAsText (Resourcearraypropertyeditor.java : 140) at Org.springframework.beans.TypeConverterDelegate.doConvertTextValue (Typeconverterdelegate.java:450) at Org.springframework.beans.TypeConverterDelegate.doConvertValue ( typeconverterdelegate.java:423) at Org.springframework.beans.TypeConverterDelegate.convertIfNecessary ( typeconverterdelegate.java:195) at Org.springframework.beans.BeanWrapperImpl.convertIfNecessary ( beanwrapperimpl.java:460) ... 2017-07-10 15:35:34,569 ERROR (org.springframework.web.context.contextloader:331)-Context initialization Failed Org.springframework.beans.factory.BeanCreationException:Error creating bean with Name ' Org.mybatis.spring.mapper.mapperscannerconfigurer#0 ' defined in class path resource [Config/applicationcontext.xml]: Cannot resolve reference to the bean ' sqlsessionfactory ' while the setting bean property ' sqlsessionfactory '; Nested exception is org.springframework.beans.factory.BeanCreationException:Error creating beans with Name ' Sqlsessionfactory ' defined in class path resource [Config/applicationcontext.xml]: Initialization of Bean failed; Nested EXception is org.springframework.beans.TypeMismatchException:Failed to convert property value of type ' java.lang.String ' To required type ' org.springframework.core.io.resource[] ' for property ' mapperlocations '; Nested exception is java.lang.IllegalArgumentException:Could not resolve resource location pattern [classpath:com/cp/
    Bank/mapper/xml/*.xml]: Class path resource [com/cp/bank/mapper/xml/] cannot is resolved to URL because it does not exist At Org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference ( beandefinitionvalueresolver.java:359) at Org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary ( beandefinitionvalueresolver.java:108) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues ( abstractautowirecapablebeanfactory.java:1469) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean ( Abstractautowirecapablebeanfactory.java:1214) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean ( abstractautowirecapablebeanfactory.java:537) at Org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean ( abstractautowirecapablebeanfactory.java:476) at org.springframework.beans.factory.support.abstractbeanfactory$1. GetObject (abstractbeanfactory.java:302) at Org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton ( defaultsingletonbeanregistry.java:230) at Org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean (abstractbeanfactory.java:298) at Org.springframework.beans.factory.support.AbstractBeanFactory.getBean (abstractbeanfactory.java:198) at Org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors ( postprocessorregistrationdelegate.java:116) at Org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostPrOcessors (abstractapplicationcontext.java:606) at Org.springframework.context.support.AbstractApplicationContext.refresh (abstractapplicationcontext.java:462) at
    Org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext (contextloader.java:403) At Org.springframework.web.context.ContextLoader.initWebApplicationContext (contextloader.java:306) at Org.springframework.web.context.ContextLoaderListener.contextInitialized (contextloaderlistener.java:106) at Org.apache.catalina.core.StandardContext.listenerStart (standardcontext.java:4939) at Org.apache.catalina.core.StandardContext.startInternal (standardcontext.java:5434) at Org.apache.catalina.util.LifecycleBase.start (lifecyclebase.java:150) at Org.apache.catalina.core.ContainerBase.addChildInternal (containerbase.java:901) at Org.apache.catalina.core.ContainerBase.addChild (containerbase.java:877) at Org.apache.catalina.core.StandardHost.addChild (standardhost.java:633) at orG.apache.catalina.startup.hostconfig.manageapp (hostconfig.java:1551) 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.uti L.modeler.basemodelmbean.invoke (basemodelmbean.java:301) 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:622) at Org.apache.catalina.mbeans.MBeanFactory.createStandardContext (mbeanfactory.java:569) 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:301) at com.sun.jmx.i Nterceptor. Defaultmbeanserverinterceptor.invoke (defaultmbeanserverinterceptor.java:819) at Com.sun.jmx.mbeanserver.JmxMBeanServer.invoke (jmxmbeanserver.java:801) 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 Javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation (rmiconnectionimpl.java:1401) 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.Unicas Tserverref.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.trans Port. 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.THR Ead.run (thread.java:745) caused by:org.springframework.beans.factory.BeanCreationException:Error creating bean with Name ' sqlsessionfactory ' defined in class path resource [Config/applicationcontext.xml]: Initialization of Bean failed; Nested exception is org.springframework.beans.TypeMismatchException:Failed to convert property value of type ' Java.lang. String ' to required type ' org.springframework.core.io.resource[] ' for property ' mapperlocations '; Nested exception is java.lang.IllegalArgumentException:Could not resolve resource location pattern [classpath:com/cp/ Bank/mapper/xml/*.xml]: Class

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.