003医疗项目-关于的问题

 

项目结构以下:java

场景以下:spring整合数据库。spring

在applicationontext.xml中配置以下:数据库

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
        http://www.springframework.org/schema/mvc 
        http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd 
        http://www.springframework.org/schema/context 
        http://www.springframework.org/schema/context/spring-context-3.1.xsd 
        http://www.springframework.org/schema/aop 
        http://www.springframework.org/schema/aop/spring-aop-3.1.xsd 
        http://www.springframework.org/schema/tx 
        http://www.springframework.org/schema/tx/spring-tx-3.1.xsd ">

<!-- 加载配置文件 -->
<context:property-placeholder location="classpath:db.properties"/>

<!-- 数据库链接池 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" >
       <property name="driverClassName" value="${jdbc.driver}"/>
        <property name="url" value="${jdbc.url}"/>
        <property name="username" value="${jdbc.username}"/>
        <property name="password" value="${jdbc.password}"/>
        <!-- 开发阶段建议最大链接数据尽可能少,够用便可 -->
        <property name="maxActive" value="${jdbc.maxActive}"/>
        <property name="maxIdle" value="${jdbc.maxIdle}"/>
</bean>

<!-- 事务管理器 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <!-- 数据源 -->
    <property name="dataSource" ref="dataSource"/>
</bean>

<!-- 通知 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
  <tx:attributes>
     <!-- 传播行为 -->
    <tx:method name="save*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
    <tx:method name="insert*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
    <tx:method name="delete*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
    <tx:method name="update*" propagation="REQUIRED" rollback-for="java.lang.Exception"/>
    <tx:method name="find*" propagation="SUPPORTS" read-only="true"/>
    <tx:method name="get*" propagation="SUPPORTS" read-only="true"/>
  </tx:attributes>
</tx:advice>

<!-- 切面 -->
<aop:config proxy-target-class="true">
  <aop:advisor advice-ref="txAdvice"
  pointcut="execution(* yycg.*.service.impl.*.*(..))"/>
</aop:config>
</beans>

上面中的apache

<!-- 加载配置文件 --> <context:property-placeholder location="classpath:db.properties"/>很奇怪,这里的db.properties明明在src/main/resources目录下。
为何这里直接写classpath就能够了。

缘由以下:
你仔细看config的图标。这个图标表示该目录是源文件夹。编译后源文件夹的非java文件会被copy到classes目录。 你能够右键 选择 build path ,而后能够把一些目录加入成为源文件夹,或者移出源文件夹。
不管有几个源文件夹,最后都会被加到classes目录里。



因此咱们打开项目的classes目录:

就能够看到这么文件。
相关文章
相关标签/搜索