Spring程序开发步骤---Spirng快速入门

通过new相应的对象来调用对象的方法。

  1. 导入Spring开发的基本包坐标(依赖)
  2. 编写Dao接口和实现类
  3. 创建Spring核心配置文件
  4. 在Spring 配置文件中配置UserDaolmpl
  5. 使用Spring的API获得Bean 实例

导入Spring开发的基本包坐标(依赖)pom.xml

<dependencies>
        <!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>5.3.3</version>
        </dependency>
    </dependencies>

编写Dao接口和实现类

创建Spring核心配置文件

在Spring 配置文件中配置UserDaolmpl

applicationContext.xml 这个名字可以随意取,但一般取这个名字

<?xml version="1.0" encoding="UTF-8"?>
<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 http://www.springframework.org/schema/beans/spring-beans.xsd">

    <!--    id 可以随意取 ; class对于Spring IOC 要管理的类-->
    <bean id="userDao" class="com.tian.dao.impl.UserDaoImpl"/>
</beans>

  • 8
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值