0
我的服務器上有兩個不同的網絡應用程序。一個是Spring mvc應用程序,另一個是struts應用程序。這些應用程序庫位於不同的位置。以下是我的春天MVC應用程序結構:如何在Spring mvc應用程序中設置類路徑?
對Spring MVC應用程序的所有jar文件在WEB-INF/lib
目錄。以下是我的web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
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">
<display-name>My project</display-name>
<servlet>
<servlet-name>route</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>route</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
當我運行春天的應用程序,它顯示了異常:
[org.springframework.web.servlet.DispatcherServlet] (MSC service thread 1-6) Context initialization failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loginDao': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.hibernate.SessionFactory com.myproject.scm.dao.LoginDao.sessionFactory; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/route-servlet.xml]: Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: org.springframework.orm.hibernate4.LocalSessionFactoryBuilder.addAnnotatedClass(Ljava/lang/Class;)Lorg/hibernate/cfg/Configuration;
但是,當我無段式應用程序運行的Spring MVC應用程序,它運行良好。也許有衝突的圖書館?
我可以在我的Spring mvc應用程序中添加classpath,以便它在適當位置查看庫罐?