《spring 4.x 企业应用开发实战》FAQ及勘误表

原创
2017/03/24 11:48
阅读数 6.6K

#FAQ

** Q1 编译时下载类库很慢,编译失败如何解决?**

答:默认Maven从中央仓库下载依赖构建包,由于网速的问题,下载很慢。一般建议安装本地私服,可参考:安装Maven私服,也可以直接使用阿里Maven私服,即更改C:\Users<用户名>.m2\settings.xml中的代码:

 <mirror>
        <id>nexus-aliyun</id>
        <mirrorOf>*</mirrorOf>
        <name>Nexus aliyun</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public</url>
    </mirror> 

具体可参见:aliyun阿里云Maven仓库地址——加速你的maven构建

#勘误表

第2章

chap2 p32 代码清单2-5 findUserByUserName()SQL错了

private  final static String MATCH_COUNT_SQL = " SELECT count(*) FROM t_user  " +
            " WHERE user_name =? `and password=?` ";

=>

private  final static String MATCH_COUNT_SQL = " SELECT count(*) FROM t_user  " +
            " WHERE user_name =?  ";

chap2 代码清单2-10 UserServiceTest

@ContextConfiguration("classpath*:/applicationContext.xml") => @ContextConfiguration("classpath*:/smart-context.xml")

第3章

chap3 代码清单3-8

spring.datasource.max-wait=10000 
spring.datasource.max-active=50 
spring.datasource.max-idle=10
spring.datasource.min-idle=8
spring.datasource.max-wait=10000
spring.datasource.max-active=100
spring.datasource.test-on-borrow=true
spring.datasource.validation-query=select 1

第1,2行删除(因与5,6行重复了)

第4章

chap4 P114 代码清单4-35 ②和③刚好反了

②工厂后处理器 => 注册Bean后处理器 ③注册Bean后处理器 =>注册工厂后处理器

**chap4 P83 包名少了一个lang **

这些反射对象类在java.reflect包中定义。

=>

这些反射对象类在java.lang.reflect包中定义。

第5章

chap5 P132

<!--②引用父容器中的car,而非②处定义的Bean,如 果采用<ref bean="car"/>将引用本容器①处的car -->

改为=>

<!--②引用父容器中的car,而非①处定义的Bean,如 果采用<ref bean="car"/>将引用本容器①处的car -->

chap5 p132 spring 4.x的<ref>移除了local属性的支持

<ref>元素可以通过以下三个属性引用容器中其他Bean。

  • bean:通过该属性可以引用同一容器或父容器的Bean,这是最常见的形式;
  • local:通过该属性只能引用同一配置文件中定义的Bean,它可以利用XML解析器自动检验引用的合法性,以便在开发编写配置时能够及时发现并纠正配置的错误;
  • parent:容器中的Bean,如<ref parent="car">的配置说明car的Bean是父容器中的Bean。

=>

<ref>元素可以通过以下两个属性引用容器中其他Bean。

  • bean:通过该属性可以引用同一容器或父容器的Bean,这是最常见的形式;
  • parent:容器中的Bean,如<ref parent="car">的配置说明car的Bean是父容器中的Bean。

** chap5 p145 **

public static int.REFRESH_CYCLE = 60; 语句中int后多了个"."

=>

public static int REFRESH_CYCLE = 60;

** chap5 p151 **

当然,Spring完全可以提供一个既实现ServletContextListener又实现ServletContextListener接口的监听器。

=>

当然,Spring完全可以提供一个既实现ServletContextListener又实现ServletRequestListener接口的监听器。

第8章

** chap8 P275 代码清单8-4 ** @AspectJ =>@Aspect

第15章

chap15 p448

<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager"
          p:cacheManager="ehcache"/>

=>

<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager"
      p:cacheManager-ref="ehcache"/>

第17章

p571 对Matrix Variable功能的默认启动状态描述有误

默认Matrix Variable功能是开启的,如果不希望开启该功能,则需要手工将RequestMappingHandlerMapping 中的 removeSemicolonContent 属性设置为true即可: <mvc:annotation-driven enable-matrix-variables="true"/>

=>

默认Matrix Variable功能是关闭的,如果希望开启该功能,则需要手工将RequestMappingHandlerMapping 中的 removeSemicolonContent 属性设置为true: <mvc:annotation-driven enable-matrix-variables="true"/>

展开阅读全文
加载中
点击加入讨论🔥(15) 发布并加入讨论🔥
15 评论
17 收藏
7
分享
返回顶部
顶部