SpringMVC_v02中的总结(web项目、java项目中引入Config.properties,加载hibernate映射文件的配置的区别)

SpringMVC_v02中的总结(web项目、java项目中引入Config.properties,加载hibernate映射文件的配置的区别)

 

1\System.out.println("1-"+new methodInService().getClass().getName()+
    "\n2- "+new methodInService().getClass().getSuperclass().getName()+
    "\n3- "+methodInService.class+
    "\n4- "+methodInService.class.getName()+
    "\n5- "+methodInService.class.getResource("")+                      编译后class文件路径    
    "\n6- "+methodInService.class.getResource("/")+                      /class
    "\n7- "+methodInService.class.getResource("/com/mvc/action/")+           切换文件加/
    "\n8- "+methodInService.class.getResource("/com/mvc/action/TestAction.class")+
    "\n9- "+methodInService.class.getResource("methodInService.class")+
    "\n10-"+methodInService.class.getResource("TestAction.class")+ //null
    
    
    "\n11-"+methodInService.class.getClassLoader().getResource("")+             /class
    "\n12-"+methodInService.class.getClassLoader().getResource("com/mvc/action/TestAction.class")          不用加/
    );
    
1-XX.Class.getClassLoader().getResourse("");                  类名直接用Class
2-new XX().getClass().getClassLoader.getResourse();      new 的类用getClass()
3-XX.Class.getResourse("/");    
   
1-com.mvc.service.methodInService
2- java.lang.Object
3- class com.mvc.service.methodInService
4- com.mvc.service.methodInService
5- file:/H:/Personal/spmvc_v02/WebRoot/WEB-INF/classes/com/mvc/service/
6- file:/H:/Personal/spmvc_v02/WebRoot/WEB-INF/classes/
7- file:/H:/Personal/spmvc_v02/WebRoot/WEB-INF/classes/com/mvc/action/
8- file:/H:/Personal/spmvc_v02/WebRoot/WEB-INF/classes/com/mvc/action/TestAction.class
9- file:/H:/Personal/spmvc_v02/WebRoot/WEB-INF/classes/com/mvc/service/methodInService.class
10-null
11-file:/H:/Personal/spmvc_v02/WebRoot/WEB-INF/classes/
12-file:/H:/Personal/spmvc_v02/WebRoot/WEB-INF/classes/com/mvc/action/TestAction.class
13-null
14-file:/H:/Personal/spmvc_v02/WebRoot/WEB-INF/classes/    
    
    
2\bean init-method  spring容器加载自动执行

 String conf = "applicationContext.xml";
  //doinit执行
    AbstractApplicationContext ac = new ClassPathXmlApplicationContext(conf);
   
3\web项目,不是java项目   

4\加载Config.properties配置文件
 --------------web------------------------
 <bean
  class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" id="propertyConfigurer">
  <property name="locations">
   <list>
    <value>/WEB-INF/classes/Config.properties</value>
   </list>
  </property>
 </bean>
 --------------web,java------------------------
 <bean
  class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" id="propertyConfigurer">
  <property name="locations">
   <list>
    <value>*.properties</value>
   </list>
  </property>
 </bean>
    ----------------------------------------------------------------
 <context:property-placeholder location="classpath*:*.properties"/> 
 
 待定(build.xml打好的jar包里执行只能用这种,上面两种执行报错???)
 build.xml中都可以用,报错的原因可能是因为spring是3.0.5版本的,但是applicationContext.xml中
  最上面引入的是3.1版本的。
 因为hibernate映射文件的路径配置错了 
 -------------------------------------------------------

5、加载Hibernate映射文件
 web项目:
  <!-- property name="mappingDirectoryLocations">
   <list>
    <value>classpath:/com/mvc/orm</value>
    
   </list>
  </property -->
 java项目: 
  <property name="mappingResources">
   <list>
    <value>com/mvc/orm/EqpEquipment.hbm.xml</value>
   </list>
  </property> 
 java项目
  <property name="mappingLocations">
      <list>
        <value>classpath*:com/test/pojo/*.hbm.xml</value>
      </list>
   </property>
 
 
 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值