Sql Server Express
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property> <property name="hibernate.connection.url">jdbc:sqlserver://localhost\SQLEXPRESS;databaseName=master;user=sa;password=password</property> <property name="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</property> </session-factory> </hibernate-configuration> |
MIS 發表在 痞客邦 留言(0) 人氣(215)
Step 01: 準備 table : TEST_GROUP & TEST_MEMBERS
table : TEST_GROUP
CREATE TABLE JAPPS.TEST_GROUP ( ID VARCHAR2(10 BYTE), NAME VARCHAR2(10 BYTE) ) |
MIS 發表在 痞客邦 留言(0) 人氣(490)

使用 EasyUI 的 Datagrid 選擇到一筆記錄後,將這一筆完整的資料要送到後端 Java 接收,可以先轉換成 JSON 的格式再後送。
UI 的圖示如下,可以用 FireBug 去查看 JavaScript 裡的資料
MIS 發表在 痞客邦 留言(0) 人氣(517)
Struts2 的 logger 是與 log4j2 作整合,同樣是 Apache Project 專案之一。為了瞭解一下與架構 Java 專案時的偵錯機制,所以花了半天的時間來實作。
Maven 對 log4j2 相依性
<properties> <struts2.version>2.3.24.1</struts2.version> <log4j2.version>2.2</log4j2.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties>
<dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> <version>${log4j2.version}</version> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>${log4j2.version}</version> </dependency>
|
MIS 發表在 痞客邦 留言(0) 人氣(9,715)
當 struts2 加入 struts2-spring-plugin 的 JAR 檔後,執行 JUnit 或 Maven build 時發生
SEVERE: [50:59.081] ********** FATAL ERROR STARTING UP STRUTS-SPRING INTEGRATION ********** Looks like the Spring listener was not configured for your web app! Nothing will work until WebApplicationContextUtils returns a valid ApplicationContext. You might need to add the following to web.xml: <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> SEVERE: [50:59.089] Dispatcher initialization failed |
MIS 發表在 痞客邦 留言(0) 人氣(116)

上次介紹 Spring Quartz Job Schedule Simple Example 工作排程器 ,現在再來使用 Spring 原生的 Task Execution and Scheduling,首先來瞭解一下 @Scheduled annotation 的意思
This annotation is used for task scheduling. The trigger information needs to be provided along with this annotation. You can use the properties fixedDelay/fixedRate/cron to provide the triggering information. 1. fixedRate: makes Spring run the task on periodic intervals even if the last invocation may be still running. 固定時間執行,不管上一次是否結束 2. fixedDelay: specifically controls the next execution time when the last execution finishes. 上一次執行結束後,再依設定的固定時間執行 3. cron: is a feature originating from Unix cron utility and has various options based on your requirements. BJ4(就不解釋了) |
MIS 發表在 痞客邦 留言(0) 人氣(305)
配置:
Maven: pom.xml
<dependency> <groupId>org.quartz-scheduler</groupId> <artifactId>quartz</artifactId> <version>2.2.2</version> </dependency> <dependency> <groupId>org.quartz-scheduler</groupId> <artifactId>quartz-jobs</artifactId> <version>2.2.2</version> </dependency> |
MIS 發表在 痞客邦 留言(0) 人氣(5,024)
看完 Spring Data JPA 基本篇 與 Spring Data JPA 進階篇 之後,再來看一下 Spring Data JPA 框架,它主要針對的就是 Spring 唯一沒有簡化到的業務邏輯代碼。接下來我們針對前面的例子進行改造,讓 Spring Data JPA 來幫助我們完成業務邏輯。在著手寫代碼之前,開發者需要先 下載Spring Data JPA 的發佈包(需要同時下載 Spring Data Commons 和 Spring Data JPA 兩個發佈包,Commons 是 Spring Data 的公共基礎包),並把相關的依賴 JAR 檔加入到 CLASSPATH 中。
MIS 發表在 痞客邦 留言(0) 人氣(10,337)
在 Spring Data JPA 基本篇 談到 JPA 的基本作業,現在加入 Spring 的注入(Dependency Injection)來看,Spring 簡化程式碼有多少.
Step 01: DAO Interface: PersonSpringDataDao.java
package com.mis.demos.dao; import com.mis.demos.model.Person; public interface PersonSpringDataDao { public Person Save(Person person); } |
MIS 發表在 痞客邦 留言(0) 人氣(1,323)

本文的示例代碼基於 Hibernate EntityManager 開發,程式碼中使用到的都是 JPA 規範提供的Interface / Class,以便瞭解 JPA 基本的概念。整個系統架構如下
Step 01 : create mysql table: person
CREATE TABLE `person` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `firstName` varchar(45) NOT NULL, `lastName` varchar(45) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8; |
MIS 發表在 痞客邦 留言(0) 人氣(6,208)