spring mvc项目启动报错

_自然醒 2014-09-01 03:13:36
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&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包截图


不知道是我引用的哪个包版本有问题,还是相关的xml文件配置写错了,求正解
...全文
135 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
lds1ove 2014-09-01
  • 打赏
  • 举报
回复
<context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:config/beans.xml</param-value> </context-param> 这个地方不是spring 的config吗
_自然醒 2014-09-01
  • 打赏
  • 举报
回复
引用 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>
sgyyz 2014-09-01
  • 打赏
  • 举报
回复
1. classpath* 这个没遇到过,应该这个有点问题。 2. spring mvc的配置没有显示的给出来,你可以试试给出来看看结果。
lds1ove 2014-09-01
  • 打赏
  • 举报
回复
classpath:* 是什么意思

67,516

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧