发表于: 2018-03-10 23:42:35

2 598


今天完成的事情:

1.学习了spring加载配置文件的5种方式

方式一:<context:property-placeholder location="classpath:jdbc.properties" ignore-unresolvable="true"/>

方式二:<bean id="prop" class="org.springframework.beans.factory.config.PropertiesFactoryBean">

          <property name="locations">

          <array> 

               <value>classpath:jdbc.properties</value> 

           </array> 

           </property>

       </bean>

方式三:使用util:properties标签进行暴露properties文件中的内容

      <util:properties id="propertiesReader" location="classpath:jdbc.properties"/>

方式四:通过propertyPlaceholderConfigurer在加载上下文的时候暴露properties到自动以子类的属性中以供程序中使用

<bean id="propertyConfigurer" class="com.hafiz.www.util.PropertyConfigurer">

    <property name="ignoreUnresolvablePlaceholders" value="true"/> 

    <property name="ignoreResourceNotFound" value="true"/>

    <property name="locations"> 

    <list> 

        <value>classpath:jdbc.properties</value> 

    </list> 

    </property>

</bean>

方式五:自定义工具类propertyUtil,并在该类的static静态代码块中读取properties文件内容保存在static属性中以供别的程序使用


2.springmvc对静态资源访问的三种方式

方式一:激活 Tomcat 的 defaultServlet 来处理静态资源 

方式二:Spring 3.0.4 以后版本提供了 <mvc:resources />

方式三:使用 <mvc:default-servlet-handler /> 

http://blog.csdn.net/seelye/article/details/51659028


3.数据库连接池的poolPreparedStatements属性

    即启用poolPreparedStatements后,PreparedStatements 和CallableStatements 都会被缓存起来复用,即相同逻辑的SQL可以复用一个游标,这样可以减少创建游标的数量。


4.

Context initialization failed 

              org.springframework.beans.factory.BeanCreationException

  

web.xml文件中必须配置spring监听器

<listener>

<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

</listener>

spring项目中监听器作用:http://www.360doc.com/content/16/0804/15/7579570_580760157.shtml


5.往数据库里面插入了100000条记录,耗时10分钟,感受了一下数据库性能。


6.核查任务一验收标准,修改了部分代码。大致符合了任务要求。


今天的问题:

今天就一个问题,耗费了很长时间。

web.xml文件没有添加spring的监听器。

<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

导致以注解方式注入bean失败。注解虽然好用,简洁,单新手使用一定要谨慎,很多坑。


明天要做的事:

任务一的深度思考!






返回列表 返回列表
评论

    分享到