zoukankan      html  css  js  c++  java
  • maven Spring获取不到配置文件

    如题:

      如果在maven项目中,Spring获取不到配置文件,

      把配置文件放到、src/main/resource文件夹下即可

    import org.springframework.context.support.ClassPathXmlApplicationContext;

    //import com.travelsky.logic.insurance.dto.InsTravelerInfo;

    public class InsureTest {
    // List<InsTravelerInfo> insTravelerInfos_Main = new ArrayList<InsTravelerInfo>();


    public static void main(String args[]) {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("danli.xml");
    Person p = (Person) ctx.getBean("personzz");
    p.setName("zhaozhi");
    System.out.println(p.getName());

    }

    }

    <?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:dubbo="http://code.alibabatech.com/schema/dubbo"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
    <context:annotation-config/>
    <context:component-scan base-package="com.*"/>
    <bean id="personzz" class="com.maintest.zz.Person">
    </bean>

    </beans>

  • 相关阅读:
    栈和队列
    绪论
    抽象数据类型和python类
    《黑马程序员》流程控制(顺序结构,选择结构,循环结构)(C语言)
    《黑马程序员》C语言中的基本运算(C语言)
    《黑马程序员》C语言中的基本数据类型 (C语言)
    《黑马程序员》 关键字、标示符、注释(C语言)
    获取图片
    文件路径
    文件上传
  • 原文地址:https://www.cnblogs.com/shoubianxingchen/p/4210367.html
Copyright © 2011-2022 走看看