• 吴裕雄--天生自然轻量级JAVA EE企业应用开发Struts2Sping4Hibernate整合开发学习笔记:Spring_ApplicationContext


    <?xml version="1.0" encoding="GBK"?>
    <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://www.springframework.org/schema/beans"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">
    </beans>
    <?xml version="1.0" encoding="GBK"?>
    <计算机书籍列表>
        <书>
            <书名>疯狂Java讲义</书名>
            <作者>李刚</作者>
        </书>
        <书>
            <书名>疯狂iOS讲义</书名>
            <作者>李刚</作者>
        </书>
    </计算机书籍列表>
    <?xml version="1.0" encoding="GBK"?>
    <project name="spring" basedir="." default="">
        <property name="src" value="src"/>
        <property name="dest" value="classes"/>
    
        <path id="classpath">
            <fileset dir="../../lib">
                <include name="**/*.jar"/>
            </fileset>
            <pathelement path="${dest}"/>
            <pathelement path="${dest}/aa"/>
        </path>
    
        <target name="compile" description="Compile all source code">
            <delete dir="${dest}"/>
            <mkdir dir="${dest}"/>
            <copy todir="${dest}">
                <fileset dir="${src}">
                    <exclude name="**/*.java"/>
                </fileset>        
            </copy>
            <javac destdir="${dest}" debug="true" includeantruntime="yes"
                deprecation="false" optimize="false" failonerror="true">
                <src path="${src}"/>
                <classpath refid="classpath"/>
                <compilerarg value="-Xlint:deprecation"/>
            </javac>
        </target>
    
        <target name="run" description="Run the main class" depends="compile">
            <java classname="lee.SpringTest" fork="yes" failonerror="true">
                <classpath refid="classpath"/>
            </java>
        </target>
    
    </project>
    <?xml version="1.0" encoding="GBK"?>
    <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://www.springframework.org/schema/beans"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">
    
    </beans>
    <?xml version="1.0" encoding="GBK"?>
    <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://www.springframework.org/schema/beans"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">
    
    </beans>
    <?xml version="1.0" encoding="GBK"?>
    <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://www.springframework.org/schema/beans"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">
    
    </beans>
    <?xml version="1.0" encoding="GBK"?>
    <计算机书籍列表>
        <书>
            <书名>疯狂Java讲义</书名>
            <作者>李刚</作者>
        </书>
        <书>
            <书名>轻量级Java EE企业应用实战</书名>
            <作者>李刚</作者>
        </书>
    </计算机书籍列表>
    <?xml version="1.0" encoding="GBK"?>
    <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://www.springframework.org/schema/beans"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">
    
    </beans>
    package lee;
    
    import org.springframework.context.*;
    import org.springframework.context.support.*;
    import org.springframework.core.io.*;
    
    import org.dom4j.io.*;
    import org.dom4j.*;
    import java.util.*;
    /**
     * Description:
     * <br/>网站: <a href="http://www.crazyit.org">疯狂Java联盟</a>
     * <br/>Copyright (C), 2001-2016, Yeeku.H.Lee
     * <br/>This program is protected by copyright laws.
     * <br/>Program Name:
     * <br/>Date:
     * @author  Yeeku.H.Lee kongyeeku@163.com
     * @version  1.0
     */
    public class SpringTest
    {
        public static void main(String[] args) throws Exception
        {
    //        ApplicationContext ctx = new
    //            FileSystemXmlApplicationContext("beans.xml");
    //        ApplicationContext ctx = new
    //            FileSystemXmlApplicationContext("classpath:beans.xml");
    //        ApplicationContext ctx = new
    //            FileSystemXmlApplicationContext("classpath*:beans.xml");
            ApplicationContext ctx = new
                ClassPathXmlApplicationContext("beans*.xml");
    //        ApplicationContext ctx = new
    //            ClassPathXmlApplicationContext("classpath*:beans*.xml");
    //        ApplicationContext ctx = new
    //            FileSystemXmlApplicationContext("classpath:beans2.xml");
            System.out.println("----" + ctx);
    //        Resource r = ctx.getResource("book.xml");
    //        Resource r = ctx.getResource("classpath:book.xml");
    //        System.out.println(r.getClass());
    //        System.out.println(r.getDescription());
        }
    }
  • 相关阅读:
    linux系统中如何进入退出vim编辑器,方法及区别
    [转]JAVA的动态代理机制及Spring的实现方式
    mybaties 缓存
    全面分析 Spring 的编程式事务管理及声明式事务管理
    面试(4)-spring-Spring面试题和答案
    vector的多套遍历方案
    【QT】QT下载与安装
    【QT】无需写connect代码关联信号和槽函数
    【QT】第一个QT程序(点击按钮,显示特定文本)
    【QT】error: 'SIGNAL' was not declared in this scope
  • 原文地址:https://www.cnblogs.com/tszr/p/12372185.html
Copyright © 2020-2023  润新知