配置spring文件时候出现的小问题

Spring中的配置bean有两种方式,今天做毕业设计的时候想使用注解的方式(简单,方便)自动扫描装配bean

大概是这样的语句

<!-- 自动扫描与装配bean -->

<context:component-scan base-package="cn.hlg.oa"></context:component-scan>

但是发现会出现一个错误

The prefix "context" for element "context:component-scan" is not bound.//大概意思就是这个东西无效,系统找不到。

对于上面这个错误的解决办法是在<beans >中加上一句

xmlns:context=http://www.springframework.org/schema/context

这个还是很好找到的,可是下一步,我足足试了两个多小时,就是这个错误解决之后,小红叉并没有消失,错误变成了

cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element ‘context:component-scan‘.

大概就是这个表情没被引进去,解决办法是在xsi:schemaLocation里面加上两句

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context-3.0.xsd

至此这个问题总算是解决了。

?

?

时间: 2024-08-29 12:19:12

配置spring文件时候出现的小问题的相关文章

如何配置Spring的XML文件及使用

App.config 1 <?xml version="1.0" encoding="utf-8" ?> 2 <configuration> 3 <configSections> 4 <sectionGroup name="spring"> 5 <section name="context" type="Spring.Context.Support.Context

Spring MVC 搭建过程中web.xml配置引入文件的路径问题

为啥要说一下这么low的问题,因为我是一个比较low的人,哈哈.本来我技术有限,没事干自己撘个环境找找乐趣,结果被各种基础问题,弄的一脸蒙蔽.算了不多说,直接说问题. 1.首先说一下java编译后的文件,正常来说我们编写的文件一般都是java文件,但实际上eclipse会帮我们编译成.class文件(在project下有个自动编译),没有编译的话,Project->Build Project 来编译当前的项目 2.上面说的都是很简单的事情,但是简单的再延伸,就可能出一点问题了,重申一下,我比较l

spring文件的配置 方便以后查看

1 <?xml version="1.0" encoding="UTF-8"?> 2 <beans xmlns="http://www.springframework.org/schema/beans" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 xmlns:aop="http://www.springframework.org

Spring 配置读文件参数

<bean id="xx" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">     <property name="order" value="10" />     <property name="ignoreUnresolvablePlaceholders" val

Spring的配置文件ApplicationContext.xml配置头文件解析

Spring的配置文件ApplicationContext.xml配置头文件解析 原创 2016年12月16日 14:22:43 标签: spring配置文件 5446 spring中的applicationContext.xml配置头文件解析 <?xmlversion="1.0"encoding="UTF-8"?> <beansxmlns="http://www.springframework.org/schema/beans"

Spring介绍及配置(XML文件配置和注解配置)

本节内容: Spring介绍 Spring搭建 Spring概念 Spring配置讲解 使用注解配置Spring 一.Spring介绍 1. 什么是Spring Spring是一个开源框架,Spring是于2003 年兴起的一个轻量级的Java 开发框架,由 RodJohnson 在其著作 Expert One-On-One J2EE Development and Design 中阐述的部分理念和原型衍生而来.它是为了解决企业应用开发的复杂性而创建的.框架的主要优势之一就是其分层架构,分层架构

配置spring所需要的jar包

spring.jar是包含有完整发布的单个jar 包,spring.jar中包含除了spring-mock.jar里所包含的内容外其它所有jar包的内容,因为只有在开发环境下才会用到 spring-mock.jar来进行辅助测试,正式应用系统中是用不得这些类的. 除了spring.jar文件,Spring还包括有其它13个独立的jar包,各自包含着对应的Spring组件,用户可以根据自己的需要来选择组合自己的jar包,而不必引入整个spring.jar的所有类文件.(1) spring-core

一步一步地配置Spring

本文旨在从一个空工程一步一步地配置Spring,空工程见上一篇文章创建Maven父子工程. 一.spring基本配置 1. 添加spring依赖 父工程pom.xml添加spring依赖 <dependencyManagement> <dependencies> <!-- 使用spring的BOM管理依赖 --> <dependency> <groupId>org.springframework</groupId> <artif

6.使用Java的方式配置spring

一.基于Java的方式配置spring 我们可以完全不使用Spring的xml方式去配置,而是全部由Java的方式配置! JavaConfig是Spring的一个子项目,在Spring4后成为了核心功能 1.实体类User.java @Component:bean注入<bean id="user" class="ustc.wzh.pojo.User"></bean> @Value("xxx"):属性值注入<prope