我正在开发一个webapp(Spring MVC 4.1.6),我想在weblogic中部署app(war文件)并测试它。我之前使用的是Tomcat而且它有效。但是当我尝试在weblogic中部署时,我会收到如下错误:
<Error> <org.springframework.web.servlet.DispatcherServlet> <BEA-000000> `<Context initialization failedorg.springframework.beans.factory.BeanDefinitionStoreException: Unexpected exception parsing XML document from ServletContext resource [/WEB-INF/spring-dispatcher-servlet.xml]; nested exception is java.lang.NoSuchMethodError: org.springframework.beans.MutablePropertyValues.add(Ljava/lang/String;Ljava/lang/Object;)Lorg/springframework/beans/MutablePropertyValues;`
我环顾四周,发现我需要在我的weblogic.xml中添加以下内容,但它没有帮助。
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
我也尝试在weblogic.xml中添加它,这也没有帮助。
<container-descriptor>
<prefer-web-inf-classes>false</prefer-web-inf-classes>
</container-descriptor>
<container-descriptor>
<prefer-application-packages>
<package-name>org.springframework.*</package-name>
</prefer-application-packages>
</container-descriptor>
无论如何我强迫weblogic使用我的webapp中的Spring库。我还查看了weblogic的lib文件夹(想删除spring库)并没有找到任何Spring库,可能是我没找对方的地方。
感谢。
答案 0 :(得分:1)
我感觉很糟糕。我的weblogic.xml的位置不对。一旦我将文件放在WEB-INF中,它就可以了。再次感谢您的帮助。
答案 1 :(得分:0)
第一步制作SpringMVC Hello程序。 创建一个新的Spring项目。 给出一个名称并选择一个模板Spring MVC Project Spring将为您创建项目所需的永恒 之后,配置pom.xml,web.xml,spring-context.xml 这里还有我的mysql hibernate等项目 http://www.mfp.co.rs/wp-content/uploads/2015/04/testHibernate.zip
答案 2 :(得分:0)
<!-- For weblogic.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<wls:weblogic-web-app
xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd">
<wls:container-descriptor>
<wls:prefer-application-packages>
<!-- Enforce Own library-->
<wls:package-name>org.slf4j</wls:package-name>
<wls:package-name>javax.inject</wls:package-name>
<!-- Enforce JPA -->
<wls:package-name>javax.persistence</wls:package-name>
</wls:prefer-application-packages>
</wls:container-descriptor>
<wls:context-root>/App</wls:context-root>
</wls:weblogic-web-app>
For web.xml
<!-- For Servlet 2.5 web.xml -->
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<!-- Configure ContextLoaderListener to use AnnotationConfigWebApplicationContext
instead of the default XmlWebApplicationContext -->
<context-param>
<param-name>contextClass</param-name>
<param-value>
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
</param-value>
</context-param>
<!-- Configuration locations must consist of one or more comma- or space-delimited
fully-qualified @Configuration classes. Fully-qualified packages may also be
specified for component-scanning -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
com.config.ApplicationConfig,
com.config.JpaConfig
</param-value>
</context-param>
<!-- Bootstrap the root application context as usual using ContextLoaderListener -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Spring Security -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>
org.springframework.web.filter.DelegatingFilterProxy
</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/</url-pattern>
</filter-mapping>
<!-- Declare a Spring MVC DispatcherServlet as usual -->
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- Configure DispatcherServlet to use AnnotationConfigWebApplicationContext
instead of the default XmlWebApplicationContext -->
<init-param>
<param-name>contextClass</param-name>
<param-value>
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
</param-value>
</init-param>
<!-- Again, config locations must consist of one or more comma- or space-delimited
and fully-qualified @Configuration classes -->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
com.config.WebMvcConfig
</param-value>
</init-param>
</servlet>
<!-- map all requests to the dispatcher servlet -->
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
</web-app>