我使用Maven创建了一个示例Web应用程序(Spring MVC)项目。我试图将它部署在Jboss保险丝容器上,但遇到一个错误或其他错误。
我使用spring mvc来创建webapp。 web.xml,调度程序servlet,控制器代码和pom.xml附在下面: 我创建了一个新的jboss fuse实例并安装了以下bundle以支持spring mvc功能
install -s mvn:org.aopalliance/com.springsource.org.aopalliance/1.0.0
features:install spring-dm
要部署war文件,请使用以下命令:
install war:mvn:com.proj.myproj.dsp/HelloWeb/0.0.1-SNAPSHOT/war?Web-ContextPath=HelloWeb
然而,捆绑包仍然处于已安装状态。当我尝试强制重启时,我收到此错误
org.eclipse.jetty.aggregate.jetty-all-server - 8.1.14.v20131031 | FAILED HelloWeb: java.lang.NoSuchMethodError: org.springframework.core.GenericTypeResolver.resolveTypeArguments(Ljava/lang/Class;Ljava/lang/Class;)[Ljava/lang/Class;
java.lang.NoSuchMethodError: org.springframework.core.GenericTypeResolver.resolveTypeArguments(Ljava/lang/Class;Ljava/lang/Class;)[Ljava/lang/Class;
at org.springframework.core.convert.support.GenericConversionService.getRequiredTypeInfo(GenericConversionService.java:260)
请指出我在这里犯的错误。以下项目代码:
Pom.xml(快照)
<groupId>com.proj.myproj</groupId>
<artifactId>HelloWeb</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>HelloWeb Maven Webapp</name>
<url>http://maven.apache.org</url>
<packaging>war</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Import-Package>
*
</Import-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>3.2.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>3.2.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.2.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.osgi</groupId>
<artifactId>spring-osgi-web</artifactId>
<version>1.2.1</version>
</dependency>
</dependencies>
Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>Spring MVC Application</display-name>
<servlet>
<servlet-name>HelloWeb</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.osgi.web.context.support.OsgiBundleXmlWebApplicationContext</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>HelloWeb</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
Dispatcher servlet
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
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/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="com.tutorialspoint" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property na***strong text***me="suffix" value=".jsp" />
</bean>
</beans>
控制器
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.ui.ModelMap;
@Controller
@RequestMapping("/hello")
public class HelloController{
@RequestMapping(method = RequestMethod.GET)
public String printHello(ModelMap model) {
System.out.println("Request comes to controller");
model.addAttribute("message", "Hello Spring MVC Framework!");
return "hello";
}
}
如果您需要任何其他详细信息,请告知我们。
答案 0 :(得分:0)
NoSuchMethodError
的原因几乎是由于库版本冲突造成的。在这种情况下,我猜测有多个版本的spring库。使用osgi:list
列出已安装的软件包。
希望这会有所帮助