Spring

作者: 山不转人自转 | 来源:发表于2019-03-17 15:18 被阅读0次

    ①.新建一个maven项目
    ②.从maven官网导入spring的三个包(最好统一spring的jar版本,我这里用的是4.3.18)


    image.png

    ③.配置spring

    <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:context="http://www.springframework.org/schema/context"
        xmlns:aop="http://www.springframework.org/schema/aop"
        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
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
        ">
        
        <bean id="person" class="com.theme.springdemo.beans.Person"></bean>
    
    </beans>
    

    ④.写实现类
    ⑤写测试类
    spring mvc结构:


    image.png

    小知识(spring中的ref使用方法):
    spring的配置文件可能会有多个
    <property name="a" ref="b" />就是找当前配置文件里的bean 也就是b
    <ref bean ="b"/> 是寻找全局中的 bean;

    相关文章

      网友评论

          本文标题:Spring

          本文链接:https://www.haomeiwen.com/subject/bfjumqtx.html