*基于ssm的校园二手市场交易平台
相关技术:Jsp+Ssm+Mysql
可以适合新手学习借鉴
相对应代码:
<?xml version="1.0" encoding="UTF-8"?><!-- 加载数据库参数 -->
<context:property-placeholder location="classpath:conf/jdbc.properties"/>
<context:component-scan base-package="com.ldu.service.impl"/>
<bean id = "dataSource" class = "com.alibaba.druid.pool.DruidDataSource" destroy-method = "close">
<!-- 数据库基本信息配置 -->
<property name = "url" value = "${druid.url}" />
<property name = "username" value = "${druid.username}" />
<property name = "password" value = "${druid.password}" />
<property name = "driverClassName" value = "${druid.driverClassName}" />
<property name = "filters" value = "${druid.filters}" />
<!-- 最大并发连接数 -->
<property name = "maxActive" value = "${druid.maxActive}" />
<!-- 初始化连接数量 -->
<property name = "initialSize" value = "${druid.initialSize}" />
<!-- 配置获取连接等待超时的时间 -->
<property name = "maxWait" value = "${druid.maxWait}" />
<!-- 最小空闲连接数 -->
<property name = "minIdle" value = "${druid.minIdle}" />
<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
<property name = "timeBetweenEvictionRunsMillis" value ="${druid.timeBetweenEvictionRunsMillis}" />
<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
<property name = "minEvictableIdleTimeMillis" value ="${druid.minEvictableIdleTimeMillis}" />
<property name = "validationQuery" value = "${druid.validationQuery}" />
<property name = "testWhileIdle" value = "${druid.testWhileIdle}" />
<property name = "testOnBorrow" value = "${druid.testOnBorrow}" />
<property name = "testOnReturn" value = "${druid.testOnReturn}" />
<property name = "maxOpenPreparedStatements" value ="${druid.maxOpenPreparedStatements}" />
<!-- 打开 removeAbandoned 功能 -->
<property name = "removeAbandoned" value = "${druid.removeAbandoned}" />
<!-- 1800 秒,也就是 30 分钟 -->
<property name = "removeAbandonedTimeout" value ="${druid.removeAbandonedTimeout}" />
<!-- 关闭 abanded 连接时输出错误日志 -->
<property name = "logAbandoned" value = "${druid.logAbandoned}" />
</bean>
<!-- 配置MyBatis的sqlSessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="configLocation" value="classpath:conf/mybatis-config.xml"></property>
<property name="mapperLocations" value="classpath:mapper/*.xml"></property>
</bean>
<!-- Mapper接口所在包名,Spring会自动查找其下的Mapper -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.ldu.dao"></property>
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
</bean>
<!-- 配置transactionManager事务管理器 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>
<!-- 配置事物通知属性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<!-- 定义事物传播特性 -->
<tx:attributes>
<tx:method name="insert" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED" />
<tx:method name="edit*" propagation="REQUIRED" />
<tx:method name="save*" propagation="REQUIRED" />
<tx:method name="add*" propagation="REQUIRED" />
<tx:method name="new*" propagation="REQUIRED" />
<tx:method name="set*" propagation="REQUIRED" />
<tx:method name="remove*" propagation="REQUIRED" />
<tx:method name="delete*" propagation="REQUIRED" />
<tx:method name="change*" propagation="REQUIRED" />
<tx:method name="check*" propagation="REQUIRED" />
<tx:method name="get*" propagation="REQUIRED" read-only="true" />
<tx:method name="find*" propagation="REQUIRED" read-only="true" />
<tx:method name="load*" propagation="REQUIRED" read-only="true" />
<tx:method name="*" propagation="REQUIRED" read-only="true" />
</tx:attributes>
</tx:advice>
<!-- 配置事物切面 -->
<aop:config>
<aop:pointcut expression="execution(* com.ldu.service.*.*(..))" id="serviceOperation"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceOperation"/>
</aop:config>
<?xml version="1.0" encoding="UTF-8"?>
<context id="DB2Tables" targetRuntime="MyBatis3">
<!--去除注释 -->
<commentGenerator>
<property name="suppressAllComments" value="true" />
</commentGenerator>
<!--数据库连接 -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://localhost:3306/squirrel"
userId="squirrel"
password="lduyfla">
</jdbcConnection>
<javaTypeResolver >
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!--生成实体类) -->
<javaModelGenerator targetPackage="com.ldu.pojo" targetProject="E:/IntelliJ_Project/squirrel/src/main/java">
<property name="enableSubPackages" value="false" />
<property name="trimStrings" value="true" />
</javaModelGenerator>
<!--生成SQLMAP文件 -->
<sqlMapGenerator targetPackage="mapper" targetProject="E:/IntelliJ_Project/squirrel/src/main/resources">
<property name="enableSubPackages" value="false" />
</sqlMapGenerator>
<!--生成xml映射文件-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.ldu.dao" targetProject="E:/IntelliJ_Project/squirrel/src/main/java">
<property name="enableSubPackages" value="false" />
</javaClientGenerator>
<!--对应数据库表 mysql可以加入主键自增 字段命名 忽略某字段等-->
<table tableName="user" domainObjectName="User" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="catelog" domainObjectName="Catelog" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="goods" domainObjectName="Goods" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="image" domainObjectName="Image" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="comments" domainObjectName="Comments" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="notice" domainObjectName="Notice" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
<table tableName="reply" domainObjectName="Reply" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table>
</context>
如有问题或者代码看不懂请联系:jjl906935093@163.com