zoukankan      html  css  js  c++  java
  • 吴裕雄--天生自然轻量级JAVA EE企业应用开发Struts2Sping4Hibernate整合开发学习笔记:Spring_composite

    <?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}"/>
        </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.BeanTest" 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">
        <bean id="exampleBean" class="org.crazyit.app.service.ExampleBean">
            <!-- 驱动Spring调用exampleBean的getPerson().setName()方法,
            以"孙悟空"作为参数 -->
            <property name="person.name" value="孙悟空"/>
        </bean>
    </beans>
    package lee;
    
    import org.springframework.context.*;
    import org.springframework.context.support.*;
    
    import org.crazyit.app.service.*;
    /**
     * 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 BeanTest
    {
        public static void main(String[] args)
        {
            ApplicationContext ctx = new
                ClassPathXmlApplicationContext("beans.xml");
            ExampleBean b = ctx.getBean("exampleBean"
                , ExampleBean.class);
            System.out.println(b.getPerson().getName());
        }
    }
    package org.crazyit.app.service;
    /**
     * 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 ExampleBean
    {
        // 定义一个Person类型的成员变量
        private Person person = new Person();
        // person的getter方法
        public Person getPerson()
        {
            return this.person;
        }
    }
    package org.crazyit.app.service;
    
    /**
     * 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 Person
    {
        private String name;
        // name的setter和getter方法
        public void setName(String name)
        {
            this.name = name;
        }
        public String getName()
        {
            return this.name;
        }
    }
  • 相关阅读:
    【CodeForces 438D 】The Child and Sequence
    【雅礼集训 2017 Day1】市场
    【POJ2528】Mayor's posters
    【NOIP模拟】图论题Graph
    【BZOJ2654】Tree
    【NOIP模拟】函数
    【NOIP模拟】箱子
    【CQOI2014】数三角形
    【USACO2009Feb】股票市场
    【APIO2009-3】抢掠计划
  • 原文地址:https://www.cnblogs.com/tszr/p/12370297.html
Copyright © 2011-2022 走看看