元素“context:component-scan”的前缀“context”未绑定
首先报这个错误,你得明白,是什么原因导致的?
答:未引入命名空间,和约束文件
解决方法:
<?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.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!-- 组件扫描器,主要是spring使用,用来扫描带有指定注解的类,将这些加载成BeanDefinition -->
<context:component-scan base-package="com.cyb.spring.service" />
</beans>
标签中加上
<!--命名空间-->
xmlns:context="http://www.springframework.org/schema/context"
<!--别名和约束文件-->
xsi:schemaLocation="http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd"

约束文件的话,请看:http://www.springframework.org/schema/beans/spring-beans.xsd
<!--别名-->
http://www.springframework.org/schema/context
<!--公网地址-->
http://www.springframework.org/schema/context/spring-context.xsd

若不加上命名空间的话bean得这样写
<beans:bean id="" class=""></beans>
元素“context:component-scan”的前缀“context”未绑定的更多相关文章
- 元素 "context:component-scan" 的前缀 "context" 未绑定的解决方案
在动态web项目(Dynamic Web Project)中,使用SpringMVC框架,新建Spring的配置文件springmvc.xml,添加扫描控制器 <context:componen ...
- context:component-scan" 的前缀 "context" 未绑定。
SpElUtilTest.testSpELLiteralExpressiontestSpELLiteralExpression(cn.zr.spring.spel.SpElUtilTest)org.s ...
- spring配置事务 元素 "tx:annotation-driven" 的前缀 "tx" 未绑定
在进行spring与mybatis整合时,启动项目报错,控制台提示“元素 "tx:annotation-driven" 的前缀 "tx" 未绑定”. 经过查找, ...
- cache:annotation-driven" 的前缀 "cache" 未绑定
问题: Caused by: org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 29 in XML ...
- [Spring Boot] Use Component Scan to scan for Bean
Component Scan is important concept when we want to create Bean. Currently we know what, for the cla ...
- [转载]Context and Interception : The .NET Context
转载自:Context and Interception : The .NET Context Every new app domain starts with a single context, c ...
- Android在Context详细解释 ---- 你不知道Context
...
- spring注解注入:<context:component-scan>以及其中的context:include-filter>和 <context:exclude-filter>的是干什么的?
转自:https://www.cnblogs.com/vanl/p/5733655.html spring注解注入:<context:component-scan>使用说明 sprin ...
- 为什么applicationContext.xml和spring-servlet.xml中都有注解过滤<context:component-scan base-package="myproject"> 和<context:component-scan base-package="myproject.controller" />
在刚学习SpringMVC框架整合时,你也许会产生疑问为什么Spring.xml和SpringMVC.xml中都有注解过滤. <context:component-scan base-packa ...
- <context:component-scan>子标签:<context:include-filter>和<context:exclude-filter>使用时要注意的地方
在Spring MVC中的配置中一般会遇到这两个标签,作为<context:component-scan>的子标签出现. 但在使用时要注意一下几点: 1.在很多配置中一般都会吧Spring ...
随机推荐
- Spring 梳理-el表达式和jstl
JSP中有这么几种元素 1: Scriptlet <% ... %> 2: 声明元素 <%! ... %> 3: Java表达式 <%= ... %> 4: 指令元 ...
- CSS技巧 (3)
关于CSS技巧的一些题目 题目列表 所有答案点击题目链接 1.下面这个左边竖条图形,只使用一个标签,可以有多少种实现方式: 2.类似下面这样的条纹边框,只使用一个标签,可以有多少种实现方式 -- 从条 ...
- Spring5源码解析3-refresh方法初探
接上回分析完register(annotatedClasses);后,现在来看一下refresh();方法. // new AnnotationConfigApplicationContext(App ...
- Java-Thread00之多线程知识准备
------  ...
- CentOS 8 网卡设置
本次测试环境是在虚拟机上测试 网卡配置文件路径:/etc/sysconfig/network-scripts/ifcfg-ens33 [root@localhost ~]# cd /etc/sysco ...
- CSS3新单位vw、vh、vmin、vmax使用详解
像 px.em 这样的长度单位大家肯定都很熟悉,前者为绝对单位,后者为相对单位.CSS3 又引入了新单位:vw.vh.vmin.vmax.下面对它们做个详细介绍. 新单位也成为视窗单位,视窗(View ...
- Vijos 1067守望者的烦恼
背景 守望者-warden,长期在暗夜精灵的的首都艾萨琳内担任视察监狱的任务,监狱是成长条行的,守望者warden拥有一个技能名叫“闪烁”,这个技能可以把她传送到后面的监狱内查看,她比较懒,一般不查看 ...
- GUI篇 tkinter (Label,Button)之一
import tkinterfrom tkinter import * # tkinter._test() # 实例化一个窗口对象base = tkinter.Tk()# 修改窗口的标题base.wm ...
- 算法学习之剑指offer(七)
题目1 题目描述 在数组中的两个数字,如果前面一个数字大于后面的数字,则这两个数字组成一个逆序对.输入一个数组,求出这个数组中的逆序对的总数P.并将P对1000000007取模的结果输出. 即输出P% ...
- java和JavaScript的注释区别
今天在学习JavaScript的注释时候,想到了跟java注释对比一下有什么区别?下面详细的对比了一下. java的注释 java在使用注释的时候分为3种类型的注释. 单行注释:在注释内容前加符号 “ ...