Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/344.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何从不同的maven项目导入spring资源?_Java_Xml_Spring_Maven_Spring Mvc - Fatal编程技术网

Java 如何从不同的maven项目导入spring资源?

Java 如何从不同的maven项目导入spring资源?,java,xml,spring,maven,spring-mvc,Java,Xml,Spring,Maven,Spring Mvc,我正在尝试构建一个web应用程序,其中一个maven项目具有客户端,另一个具有安全性。我的maven依赖项是正确的,但我无法在安全模块中加载资源 这是我的web.xml(src/main/webapp/web-INF/web.xml): 使用META-INF作为spring文件位置不是一个好的做法。我认为它不是类路径的一部分。在Maven项目中,通常将其添加到resources文件夹下 e、 g.src/main/resources/spring/ 移动文件并尝试以下配置 <beans:i

我正在尝试构建一个web应用程序,其中一个maven项目具有客户端,另一个具有安全性。我的maven依赖项是正确的,但我无法在安全模块中加载资源

这是我的web.xml(src/main/webapp/web-INF/web.xml):


使用META-INF作为spring文件位置不是一个好的做法。我认为它不是类路径的一部分。在Maven项目中,通常将其添加到resources文件夹下

e、 g.
src/main/resources/spring/

移动文件并尝试以下配置

<beans:import
    resource="classpath:/spring/appServlet/servlet-security.xml" />

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:util="http://www.springframework.org/schema/util" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<!-- <beans:bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
    <beans:property name="location" value="classpath:resources.properties"> </beans:property> 
    </beans:bean> -->
<beans:import
    resource="classpath:/META-INF/spring/appServlet/servlet-security.xml" />
</beans:beans>
    <?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security-3.0.3.xsd">
 
    <http auto-config="true"  use-expressions="true">
        <intercept-url pattern="/login" access="permitAll" />
        <intercept-url pattern="/logout" access="permitAll" />
        <intercept-url pattern="/accessdenied" access="permitAll" />
        <intercept-url pattern="/**" access="hasRole('ROLE_USER')" />
        <form-login login-page="/login" default-target-url="/list" authentication-failure-url="/accessdenied" />
        <logout logout-success-url="/logout" />
    </http>
 
    <authentication-manager alias="authenticationManager">
        <authentication-provider>
            <user-service>
                <user name="vitorn" password="password1" authorities="ROLE_USER" />
            </user-service>
        </authentication-provider>
    </authentication-manager>
</beans:beans>
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [META-INF/spring/appServlet/servlet-security.xml]
ERROR: org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:/META-INF/spring/appServlet/servlet-security.xml]
Offending resource: ServletContext resource [/WEB-INF/spring/root-context.xml]; nested exception is org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [META-INF/spring/appServlet/servlet-security.xml]; nested exception is java.io.FileNotFoundException: class path resource [META-INF/spring/appServlet/servlet-security.xml] cannot be opened because it does not exist
    at org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)
<beans:import
    resource="classpath:/spring/appServlet/servlet-security.xml" />