新建一个空白的maven项目
导入spring依赖包
<!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>5.2.0.RELEASE</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.springframework/spring-jdbc -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>5.2.0.RELEASE</version>
</dependency>
基于Dao层,业务层,用户层
例
服务层利用set注入值
1.区别与之前,程序是主动创建对象 。
2.利用set注入后,程序被动接受对象,耦合性大大降低。