close

  Struts 2.1.8版於今年九月三十日釋出。早在2.1.6版釋出,就有不少變革,手上電腦簡體書進度就跟不上。畢竟Struts2的版本其實都該減1,因為Struts 1和Struts 2關係是八竿子打不著,硬湊而成。

  情形是我把一本叫程序天下的JPA裡的blog飯粒移到Maven去煮,用最新的Struts 2.1.8和Spring 2.5.6去調味,原光碟裡的lib附了太多未必用到的過期罐頭(jar)。

  第一道菜是Error creating bean with name 'entityManagerFactory' defined in file […略]: Invocation of init method failed; nested exception is java.lang.NoSuchFieldError: TRACE。原本還有個org.slf4j.impl.StaticLoggerBinder的Exception,現在無法重現出,也間接知道問題出在SLF4J身上,我就加dependcy到最新的版本1.5.8:

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.5.8</version>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>1.5.8</version>
</dependency>

  SLF4J全名是Simple Logger Facade for Java,目的在於統一Log4J、java.util.logging、org.apache.commons.logging、logback(沒聽過)等log framework。唉!煩不煩啊!以前南韓政壇有感於政府有一堆養米蟲的委員會太多浪費公帑,經過決議,成立一個委員會來消滅這些委員會…XD。

  第二、三道菜其實指的是同一個問題材料所煮。

  • Could not load the FreeMarker template named 'head':
    Attempted: /template/ajax/head.ftl
    The TemplateLoader provided by the FreeMarker Configuration was a: freemarker.cache.MultiTemplateLoader
  • Expression parameters.parseContent is undefined on line 45, column 28 in template/ajax/head.ftl. - Class: freemarker.core.TemplateObject

  到了2.1.6版,把原來在struts tag裡的ajax如<struts:head/>、<struts:datetimepicker/>還有tree、treenode等,都移到dojo-plugin,是故需要再加以下的dependcy:

<dependency>
    <groupId>org.apache.struts</groupId>
    <artifactId>struts2-dojo-plugin</artifactId>
    <version>${struts.version}</version>    <!-- 跟著最新的Struts2版本跑 -->
</dependency>

  看來Struts2對Dojo挺不錯的。而到2.1.8版,據稱已支援osgi-plugin了。拜這頓飯粒所賜,也領教了Hibernate自動在MySQL生成Table的威力。

arrow
arrow
    全站熱搜

    Jemmy 發表在 痞客邦 留言(0) 人氣()