springbootstrap.java

来自「一些很有用的spring的书籍」· Java 代码 · 共 35 行

JAVA
35
字号
package com.apress.springbook.chapter01;

import java.io.FileInputStream;
import java.util.Properties;

import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.FileSystemResource;

public class SpringBootstrap {
    public static void main(String[] args) throws Exception {

        /* Check if the location of the configuration file has been passed
         * as an argument.
         */
        if (args.length == 0) {
	  throw new IllegalArgumentException("Please provide the location of a " +
	          "Spring configuration file as argument!");
        }

        /* Call the Spring Framework API here! */
        XmlBeanFactory factory = 
          new XmlBeanFactory(new FileSystemResource(args[0]));

	DemonstratingBean demoBean = (DemonstratingBean)factory.getBean("bean");

	System.out.println("Bean property value: " + demoBean.getName());

        /* pause the application until a key is pressed */
        System.out.println("Press any key to close the application");
        System.in.read();

        /* Key has been pressed, close the application and exit */
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?