• spring(23种设计模式环境)


    目录:

    ClassA.java

    package cn.itcast.domain;
    
    public class ClassA {
        public String say() {
            return "Hello World!";
        }
    }

    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" xmlns:p="http://www.springframework.org/schema/p"
        xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:context="http://www.springframework.org/schema/context"
        xsi:schemaLocation="http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context-4.0.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop-4.0.xsd">
        <bean id="classA" class="cn.itcast.domain.ClassA" />
    </beans>

    ClassTest.java

    package cn.itcast.dao.test;
    
    import org.junit.Test;
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    
    import cn.itcast.domain.ClassA;
    
    public class ClassTest {
        @Test
        public void test() {
            ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
            ClassA classA = (ClassA) ctx.getBean("classA");
            classA.say();
        }
    }

    测试结果:

  • 相关阅读:
    Vue2.1.7源码学习
    JavaScript 复制对象【Object.assign方法无法实现深复制】
    数组去重你知道几种?
    基于webpack2.x的vue2.x的多页面站点
    欲练JS,必先攻CSS——前端修行之路
    闭包的7种形式
    遇见未知的CSS
    redux 个人整理
    log4j.properties打印日志信息(1)
    Java Web开发之Servlet、JSP基础
  • 原文地址:https://www.cnblogs.com/jianfengyun/p/3734301.html
Copyright © 2020-2023  润新知