见鬼了,spring的配置文件里面少了一句,怎么别人的包导过来就可以,我自己写的少了就不行呢

行业混子 2019-01-24 10:04:15
这是我复制他的xml文件,就改了一下类名
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.3.xsd">

<!-- 使用 context 命名空间 ,在配置文件中开启相应的注解处理器 -->
<context:annotation-config />

<bean id="userDao"
class="com.annotation.UserDaoImpl" />
<bean id="userService"
class="com.annotation.UserServiceImpl" autowire="byName" />
<bean id="userControl"
class="com.annotation.UserControl" autowire="byName"/>
</beans>
他的xml文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.3.xsd">
<bean id="userDao"
class="com.itheima.annotation.UserDaoImpl" />
<bean id="userService"
class="com.itheima.annotation.UserServiceImpl" autowire="byName" />
<bean id="userController"
class="com.itheima.annotation.UserController" autowire="byName"/>
</beans>

少了 <context:annotation-config /> 这一句,怎么我的删了这一句就不能运行,他的却可以?
...全文
621 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
jianixia 2019-02-20
  • 打赏
  • 举报
回复
真的长见识了!
行业混子 2019-02-20
  • 打赏
  • 举报
回复
引用 1 楼 oldmee 的回复:
使用<context:component-scan/>后,可将<context:annotation-config/>省去。 都有这个功能: 向Spring容器注册AutowiredAnnotationBeanPostProcessor、RequiredAnnotationBeanPostProcessor、CommonAnnotationBeanPostProcessor以及PersistenceAnnotationBeanPostProcessor这4个BeanPostProcessor
还有这种,长见识了
行业混子 2019-02-20
  • 打赏
  • 举报
回复
引用 5 楼 yeness 的回复:
这项目够老的了,话说近几年不都是springboot了吗?

加了这句,我记得服务器的当前上下文就能够用类的实例了,否则不能用吧
<!-- 使用 context 命名空间 ,在配置文件中开启相应的注解处理器 -->
<context:annotation-config />
那是不是该学springboot 啊?我初学者
行业混子 2019-02-20
  • 打赏
  • 举报
回复
引用 5 楼 yeness 的回复:
这项目够老的了,话说近几年不都是springboot了吗?

加了这句,我记得服务器的当前上下文就能够用类的实例了,否则不能用吧
<!-- 使用 context 命名空间 ,在配置文件中开启相应的注解处理器 -->
<context:annotation-config />
这是我在练习,没有做项目
xuan.ye 2019-02-14
  • 打赏
  • 举报
回复
这项目够老的了,话说近几年不都是springboot了吗?

加了这句,我记得服务器的当前上下文就能够用类的实例了,否则不能用吧
<!-- 使用 context 命名空间 ,在配置文件中开启相应的注解处理器 -->
<context:annotation-config />

一定要细心 2019-02-01
  • 打赏
  • 举报
回复
你看他有没有其他的xml文件中有<context:component-scan/>
loveunittesting 2019-01-29
  • 打赏
  • 举报
回复
是不是ide导入工程的时候有问题,jar包冲突
oldmee 2019-01-25
  • 打赏
  • 举报
回复
使用<context:component-scan/>后,可将<context:annotation-config/>省去。 都有这个功能: 向Spring容器注册AutowiredAnnotationBeanPostProcessor、RequiredAnnotationBeanPostProcessor、CommonAnnotationBeanPostProcessor以及PersistenceAnnotationBeanPostProcessor这4个BeanPostProcessor

67,513

社区成员

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

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