1、新建一个spring-mvc工程,java工程即可。

2、目录结构,导入五个基本的jar包。

spring-1

3、创建applicationContext.xml文件,引入xsd(用于约束xml文件可以出现的标签和标签出现的顺序),可以在下载的spring源码里面查看applicationContext.xml文件,看是如何引入xsd的。

另一种创建applicationContext.xml的方法,在src-->new -->other-->spring-->Spring Bean Configuration File

spring-1

4、applicationContext.xml配置如下代码。

 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     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
 5 
 6 <bean class="com.spring.service.SpringService" >
 7     <property name="userName" value="lvyf">
 8          
 9     </property>
10 </bean>
11 </beans>
View Code

相关文章:

  • 2021-06-28
  • 2022-01-13
  • 2021-05-23
  • 2022-01-13
  • 2021-07-23
  • 2021-05-18
  • 2021-06-19
  • 2022-03-10
猜你喜欢
  • 2021-04-14
  • 2021-07-30
  • 2021-11-29
  • 2021-05-21
  • 2021-06-25
  • 2021-07-11
  • 2022-02-06
相关资源
相似解决方案