spring mvc项目启动报错

J2EE 码拜 9年前 (2015-04-13) 1314次浏览 0个评论

spring mvc 项目启动时候报这个错误
java.lang.NoSuchMethodError: org.springframework.web.context.support.XmlWebApplicationContext.getEnvironment()

web.xml的部分代码如下 

    <context-param>  
        <param-name>contextConfigLocation</param-name>  
        <param-value>classpath*:config/beans.xml</param-value>  
      </context-param>  
        
      <listener>  
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  
      </listener>  
      <listener>  
        <listener-class>org.springframework.web.context.ContextCleanupListener</listener-class>  
      </listener>  
        
      <servlet>  
        <servlet-name>spring-mvc</servlet-name>  
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>  
        <load-on-startup>1</load-on-startup>  
      </servlet>  
      <servlet-mapping>  
        <servlet-name>spring-mvc</servlet-name>  
        <url-pattern>/</url-pattern>  
      </servlet-mapping>  

 

beans.xml代码如下

    <configuration>  
            <typeAliases>  
                <!-- 给实体类起一个别名 user -->  
                <typeAlias type="com.domain.User" alias="User"/>  
                <typeAlias type="com.domain.Article" alias="Article"/>  
            </typeAliases>  
            <!-- 对数据库的配置, -->  
            <environments default="development">  
                <environment id="development">  
                    <transactionManager type="jdbc"/>  
                    <dataSource type="POOLED">  
                        <property name="driver" value="com.mysql.jdbc.Driver"/>  
                        <property name="url" value="jdbc:mysql://localhost:3306/mybatis?useUnicode=true&amp;characterEncoding=utf8"/>  
                        <property name="username" value="root"/>  
                        <property name="password" value="root"/>  
                    </dataSource>  
                </environment>  
            </environments>  
            <mappers>  
                <mapper resource="com/domain/userMapper.xml"/>  
            </mappers>  
       </configuration>  

具体使用的jar包截图
spring mvc项目启动报错

不知道是我引用的哪个包版本有问题,还是相关的xml文件配置写错了,求正解

spring mvc项目启动报错
classpath:* 是什么意思
spring mvc项目启动报错
10分
1. classpath* 这个没遇到过,应该这个有点问题。
2. spring mvc的配置没有显示的给出来,你可以试试给出来看看结果。
spring mvc项目启动报错
引用 2 楼 sgyyz 的回复:

1. classpath* 这个没遇到过,应该这个有点问题。
2. spring mvc的配置没有显示的给出来,你可以试试给出来看看结果。
这个是spring-mvc-servler.xml的相关信息 ,是这个吗

<context:component-scan base-package="com.controller"></context:component-scan>

	<mvc:annotation-driven />

	<mvc:resources location="/WEB-INF/static/" mapping="/static/*" />

	<mvc:default-servlet-handler />

	<bean
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix">
			<value>/WEB-INF/pages/</value>
		</property>
		<property name="suffix">
			<value>.jsp</value>
		</property>
	</bean>
spring mvc项目启动报错
10分
   <context-param>  
        <param-name>contextConfigLocation</param-name>  
        <param-value>classpath*:config/beans.xml</param-value>  
      </context-param>  

这个地方不是spring 的config吗


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明spring mvc项目启动报错
喜欢 (0)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!