毕业设计项目开发日志1

来源:互联网 发布:unity3d 画虚线 编辑:程序博客网 时间:2024/05/16 06:28

前期完成了前端页面和数据库构建,现在开始进行后台系统开发

准备用ssm框架整合开发系统,但是mybatis不熟悉,还有应该会用到hibernate,也是不熟悉,不过时间还长,足够慢慢探索开发



基于广电运通的人脸识别后台管理系统,参照进行开发

先进行spring的准备


一、Spring组件扫描context:component-scan

1.不想在spring配置文件中配置bean,就加上<context:component-scan base-package="jar包位置"></context:component-scan>,如此可以实现bean的自动载入

2.下面是引用spring framework开发手册中的一段话
Spring 2.5引入了更多典型化注解(stereotype annotations): @Component@Service和 @Controller@Component是所有受Spring管理组件的通用形式;而@Repository@Service和 @Controller则是@Component的细化,用来表示更具体的用例(例如,分别对应了持久化层、服务层和表现层)。也就是说,你能用@Component来注解你的组件类,但如果用@Repository@Service @Controller来注解它们,你的类也许能更好地被工具处理,或与切面进行关联。例如,这些典型化注解可以成为理想的切入点目标。当然,在Spring Framework以后的版本中, @Repository@Service和 @Controller也许还能携带更多语义。如此一来,如果你正在考虑服务层中是该用@Component还是@Service,那@Service显然是更好的选择。同样的,就像前面说的那样, @Repository已经能在持久化层中进行异常转换时被作为标记使用了。”

3.有了<context:component-scan>,另一个<context:annotation-config/>标签根本可以移除掉,因为已经被包含进去了。

4.<context:component-scan>提供两个子标签:<context:include-filter>和<context:exclude-filter>各代表引入和排除的过滤。
如:<context:component-scan base-package="com.xhlx.finance.budget" >
<context:include-filter type="regex" expression=".service.*"/>
</context:component-scan>
5.filter标签在Spring3有五个type,如下:
Filter TypeExamples ExpressionDescriptionannotationorg.example.SomeAnnotation符合SomeAnnoation的target classassignableorg.example.SomeClass指定class或interface的全名aspectjorg.example..*Service+AspectJ语法regexorg\.example\.Default.*Regelar Expressioncustomorg.example.MyTypeFilterSpring3新增自訂Type,实作org.springframework.core.type.TypeFilter


二、系统中需要加载多个Properties配置文件

<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:配置文件位置" />
</bean>



三、数据源配置, 使用 BoneCP 数据库连接池
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">

<property name="driverClassName" value="${driver}" />  
        <property name="url" value="${url}" />  
        <property name="username" value="${username}" />  
        <property name="password" value="${password}" />  
        <!-- 初始化连接大小 -->  
        <property name="initialSize" value="${initialSize}"></property>  
        <!-- 连接池最大数量 -->  
        <property name="maxActive" value="${maxActive}"></property>  
        <!-- 连接池最大空闲 -->  
        <property name="maxIdle" value="${maxIdle}"></property>  
        <!-- 连接池最小空闲 -->  
        <property name="minIdle" value="${minIdle}"></property>  
        <!-- 获取连接最大等待时间 -->  
        <property name="maxWait" value="${maxWait}"></property>  
    </bean>


jdbc.properties配置文件

driver=com.mysql.jdbc.Driver  url=jdbc\:mysql\://localhost\:5200/zzxdb  username=root\t  password=zzx2016  initialSize=0  maxActive=20  maxIdle=20  minIdle=1  maxWait=60000  



四、声明事务  
<bean id="transactionManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
参考http://blog.csdn.net/yeson6/article/details/4954330



0 0
原创粉丝点击