搭建步骤
- 先创建空maven项目
- pom文件导入相应依赖jar包
- 再创建包结构(domain、test即可)
- 然后创建JavaBean配置文件
- 最后编写简单示例和测试下效果
详细步骤
- 创建空maven项目
创建空maven项目完成。
- pom文件导入相应依赖jar包
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.2.0.RELEASE</version>
</dependency>
</dependencies>
3. 编写简单javabean实体类
4、配置相对应的beans.xml配置文件,以便springIOC容器可以创建对象,记得要有set方法!
<?xml version="1.0" encoding="UTF8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- bean 就是Java对象,由spring创建和管理-->
<bean id="hello" class="com.rizhao.test.hello">
<property name="name" value="spring"/>
</bean>
</beans>
``5、编写测试类,简单的测试一下