用Spring写[IBS:商贸管理系统]需要的Jar包和齐全配置

本文介绍了构建Spring驱动的IBS商贸管理系统所需的7个核心配置文件,包括Spring.XML、SpringMVC.XML、Spring-Shiro.XML、Spring-Email.XML、Spring-quartz.XML、Web-Xml和pom-XML。每个配置文件的功能和作用都有所涉及,为后续深入探讨这些配置之间的关系奠定了基础。
摘要由CSDN通过智能技术生成

一共是7个配置文件:下次给大家分享他们的关系配置属性

1.Spring.XML

2.SpringMVC.XML

3.Spring-Shiro.XML

4.Spring-Email.XML

5.Spring-quartz.XML

6.Web-Xml

7.pom-XML

1。Spring.XML的配置
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xmlns:jpa="http://www.springframework.org/schema/data/jpa"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
    <!-- 扫描包
        @Controller @Service @Repository @Component
    -->
    <context:component-scan base-package="cn.itsource.service"/>
    <context:component-scan base-package="cn.itsource.easypoi"/>
    <!-- 开启Spring的注解支持 -->
    <context:annotation-config/>

    <!--
          1)配置数据库连接池
              dbcp.properties
          2)配置JPA的EntityManagerFactory,使用FactoryBean的方式配置
          3)支持全注解的事务管理 在Service层的实现类或者方法上面添加@Transactional注解即可
      -->
    <!--引入dbcp.properties文件-->
    <context:property-placeholder location="classpath:dbcp.properties"/>
    <!--配置dbcp连接池-->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
        <!--通常情况下以下四个key都要加前缀-->
        <property name="driverClassName" value="${jdbc.driverClassName}"/>
        <property name="url"             value="${jdbc.url}"/>
        <property name="username"        value="${jdbc.username}"/>
        <property name="password"        value="${jdbc.password}"/>
    </bean>

    <!--配置JPA的EntityManagerFactory【FactoryBean方式配置】-->
    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <!--引用一个数据库连接池-->
        <property name="dataSource" ref="dataSource"/>
        <!--指定我们的domain实体类【加了@Entity注解的实体类】在哪个包-->
        <property name="packagesToScan" value="cn.itsource.domain"/>
        <!--指定一个适配器-->
        <property name="jpaVendorAdapter">
            <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                <!--配置方言-->
                <property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect"/>
                <!--建表策略-->
                <property name="generateDdl" value="false"/>
                <!--是否显示SQL-->
                <property name="showSql" value="true"/>
            </bean>
        </property>
    </bean>

    <!-- Service层添加事务管理【全注解添加事务管理】 -->
    <bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactory"/>
    </bean>
    <!--
        开启注解直接AOP
        tx:annotation-driven 表示开启注解支持Spring的事务管理【AOP】,会查找默认的bean名称:transactionManager
            transaction-manager属性可以指定事务管理器的bean名称,如果不指定默认找transactionManager
    -->
    <tx:annotation-driven transaction-manager="txManager"  />
    <!-- Spring Data Jpa配置 ********************************************-->
    <!-- base-package:扫描的包 -->
    <jpa:repositories base-package="cn.itsource.dao"
                      transaction-manager-ref="txManager" />

    <!--
      以下是集成SpringDataJPA的配置
          base-package 表示指定一个包名,因为SpringDataJPA的DAO层只需要写接口,不需要写实现类【牛逼得很】
              因为没有实现类,有需要创建对象,所以SpringDataJPA自动帮我们生成一个实现类,
              所以扫描包就不能再使用context:component-scan扫描了,因为没有实现类,不能添加@Repository注解
          factory-class="cn.itsource.factorybean.MyRepositoryFactoryBean"
              SpringDataJPA默认使用SimpleJPARepository类作为自动生成的类的父类,如果需要修改就必须设置factory-class属性
  -->
    <jpa:repositories base-package="cn.itsource.dao" transaction-manager-ref="txManager"
                      factory-class="cn.itsource.factorybean.MyRepositoryFactoryBean" />

    <!-- 引入spring-shiro.xml -->
    <import resource="classpath:spring-shiro.xml"/>
</beans>

2。 SpringMVC.XML的配置
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/mvc http://www.springframework.org/sch
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值