UNIX에서 하위 폴더의 JSP파일을 touch 하고자 할 경우,
find . -name '*.jsp' -exec touch {} \;
UNIX에서 하위 폴더 전부를 touch 하고자 할 경우,
find . -exec touch {} \;
또는
find . -print | xargs touch
2014년 6월 24일 화요일
2014년 6월 2일 월요일
파일 업로드를 위한 Spring 설정
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize"> <value>50000000</value> </property>
</bean>
<!-- file upload controller 셋팅 -->
<bean id="uploadControl" class="com.disc.gwp.control.FileUploadControl">
<property name="destinationDir" value="/groupware/attach/gwp/tempUpload" />
<property name="fileService" ref="fileService" />
<property name="boardService" ref="boardService" />
</bean>
파일 업로드 Controller 소스.
package com.linuxwan.control;
import jada.common.util.StringUtil;
import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.StringTokenizer;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.util.FileCopyUtils;
import org.springframework.validation.BindException;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.support.ByteArrayMultipartFileEditor;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractCommandController;
import org.springframework.web.util.WebUtils;
import com.linuxwan.ibatis.domain.Ca002m;
import com.linuxwan.ibatis.domain.Ca002t;
import com.linuxwan.ibatis.domain.Ca002tExample;
import com.linuxwan.service.BoardService;
import com.linuxwan.service.FileService;
import com.linuxwan.session.UserSession;
import com.linuxwan.util.GenSequenceNo;
/**
* @author
*/
public class FileUploadControl extends AbstractCommandController {
private static Log logger = LogFactory.getLog(FileUploadControl.class);
private FileService fileService = null;
private BoardService boardService = null;
private String destinationDir;
public FileUploadControl() {
setCommandClass(Ca002t.class);
}
/**
* 파일업로드를 위한 빈 설정의 property
* destinationDir setter injection
* @param destinationDir
*/
public void setDestinationDir(String destinationDir) {
this.destinationDir = destinationDir;
}
/**
* FileService setter Injection
* @param fileService
*/
public void setFileService(FileService fileService) {
this.fileService = fileService;
}
public FileService getFileService() {
return this.fileService;
}
public void setBoardService(BoardService boardService) {
this.boardService = boardService;
}
public BoardService getBoardService() {
return this.boardService;
}
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder)
throws ServletException {
binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
}
/* (non-Javadoc)
* @see org.springframework.web.servlet.mvc.AbstractCommandController#handle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.Object, org.springframework.validation.BindException)
*/
@Override
protected ModelAndView handle(HttpServletRequest request, HttpServletResponse response,
Object command, BindException errors)
throws Exception {
// TODO Auto-generated method stub
ModelAndView mav = new ModelAndView("common/file_search_popup_01");
String mode = StringUtil.null2void(request.getParameter("mode"));
String cntnId = StringUtil.null2void(request.getParameter("cntnId"));
String dcmtRgsrNo = StringUtil.null2void(request.getParameter("dcmtRgsrNo"));
String attachList = StringUtil.null2void(request.getParameter("attachList"));
UserSession userSession = (UserSession) WebUtils.getRequiredSessionAttribute(request, "userSession");
FileService fileService = (FileService) getFileService();
BoardService boardService = (BoardService) getBoardService();
ArrayList<Ca002t> attach = new ArrayList<Ca002t>();
Ca002t ts002t = null;
if (attachList != null && attachList != "") {
StringTokenizer files = new StringTokenizer(attachList, "^");
while (files.hasMoreTokens()) {
ts002t = new Ca002t();
StringTokenizer token = new StringTokenizer(files.nextToken(), "|");
while(token.hasMoreTokens()) {
ts002t.setSysFileName(token.nextToken());
ts002t.setOrgnFileName(token.nextToken());
attach.add(ts002t);
}
}
}
if (mode.equals("ADD")) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
MultipartFile file = multipartRequest.getFile("file");
String fileName = file.getOriginalFilename();
String sysFileName = GenSequenceNo.getFileRgsrNo(userSession.getEmpNo());
File destination = File.createTempFile(sysFileName, "", new File(destinationDir));
FileCopyUtils.copy(file.getInputStream(), new FileOutputStream(destination));
Ca002t fileVO = (Ca002t) command;
fileVO.setOrgnFileName(file.getOriginalFilename());
fileVO.setSysFileName(sysFileName);
fileVO.setFileSize(file.getSize());
fileVO.setFileData(file.getBytes());
fileService.addTempFileUpload(fileVO);
destination.delete();
attach.add(fileVO);
if (attachList.trim().equals("")) {
attachList = fileVO.getSysFileName() + "|" + fileVO.getOrgnFileName();
} else {
attachList = attachList + "^" + fileVO.getSysFileName() + "|" + fileVO.getOrgnFileName();
}
mav.addObject("mode", "ADD");
mav.addObject("attachFileList", attachList);
mav.addObject("attachList", attach);
} else if (mode.equals("DEL")) {
String delFile = StringUtil.null2void(request.getParameter("delFile"));
StringTokenizer token = new StringTokenizer(delFile, "|");
String orgnFileName = "";
String sysFileName = "";
while(token.hasMoreTokens()) {
sysFileName = token.nextToken();
orgnFileName = token.nextToken();
}
Ca002tExample example = new Ca002tExample();
Ca002tExample.Criteria c = example.createCriteria();
c.andSysFileNameEqualTo(sysFileName);
c.andOrgnFileNameEqualTo(orgnFileName);
fileService.removeTempFileUpload(example);
for (int i = 0; i < attach.size(); i++) {
Ca002t temp = (Ca002t) attach.get(i);
if (temp.getSysFileName().equals(sysFileName)) attach.remove(i);
}
attachList = "";
for (int i = 0; i < attach.size(); i++) {
Ca002t fileVO = (Ca002t) attach.get(i);
if (i == 0) {
attachList = fileVO.getSysFileName() + "|" + fileVO.getOrgnFileName();
} else {
attachList = attachList + "^" + fileVO.getSysFileName() + "|" + fileVO.getOrgnFileName();
}
}
mav.addObject("mode", "DEL");
mav.addObject("attachFileList", attachList);
mav.addObject("attachList", attach);
} else if (mode.equals("LIST")) {
// Temp 테이블에 첨부파일이 등록되어져 있는지 확인
int fileCnt = attach.size();
Ca002m attachFile = new Ca002m();
attachFile.setCntnId(cntnId);
attachFile.setDcmtRgsrNo(dcmtRgsrNo);
attachList = "";
for (int i = 0; i < fileCnt; i++) {
Ca002t tempFile = attach.get(i);
attachFile.setOrgnFileName(tempFile.getOrgnFileName());
attachFile.setSysFileName(tempFile.getSysFileName());
Ca002tExample example = new Ca002tExample();
Ca002tExample.Criteria criteria = example.createCriteria();
criteria.andSysFileNameEqualTo(tempFile.getSysFileName());
criteria.andOrgnFileNameEqualTo(tempFile.getOrgnFileName());
boolean check = fileService.findCheckTempFileUpload(example);
// Temp 테이블에 첨부파일이 없을 경우
if (!check) {
Ca002m result = boardService.findAttachFileInfo(attachFile);
Ca002t insTempFile = new Ca002t();
insTempFile.setOrgnFileName(result.getOrgnFileName());
insTempFile.setSysFileName(result.getSysFileName());
insTempFile.setFileSize(result.getFileSize());
insTempFile.setFileData(result.getFileData());
fileService.addTempFileUpload(insTempFile);
}
if (i == 0) {
attachList = tempFile.getSysFileName() + "|" + tempFile.getOrgnFileName();
} else {
attachList = attachList + "^" + tempFile.getSysFileName() + "|" + tempFile.getOrgnFileName();
}
}
mav.addObject("mode", "LIST");
mav.addObject("attachFileList", attachList);
mav.addObject("attachList", attach);
}
mav.addObject("cntnId", cntnId);
mav.addObject("dcmtRgsrNo", dcmtRgsrNo);
return mav;
}
}
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize"> <value>50000000</value> </property>
</bean>
<!-- file upload controller 셋팅 -->
<bean id="uploadControl" class="com.disc.gwp.control.FileUploadControl">
<property name="destinationDir" value="/groupware/attach/gwp/tempUpload" />
<property name="fileService" ref="fileService" />
<property name="boardService" ref="boardService" />
</bean>
파일 업로드 Controller 소스.
package com.linuxwan.control;
import jada.common.util.StringUtil;
import java.io.File;
import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.StringTokenizer;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.util.FileCopyUtils;
import org.springframework.validation.BindException;
import org.springframework.web.bind.ServletRequestDataBinder;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.multipart.support.ByteArrayMultipartFileEditor;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractCommandController;
import org.springframework.web.util.WebUtils;
import com.linuxwan.ibatis.domain.Ca002m;
import com.linuxwan.ibatis.domain.Ca002t;
import com.linuxwan.ibatis.domain.Ca002tExample;
import com.linuxwan.service.BoardService;
import com.linuxwan.service.FileService;
import com.linuxwan.session.UserSession;
import com.linuxwan.util.GenSequenceNo;
/**
* @author
*/
public class FileUploadControl extends AbstractCommandController {
private static Log logger = LogFactory.getLog(FileUploadControl.class);
private FileService fileService = null;
private BoardService boardService = null;
private String destinationDir;
public FileUploadControl() {
setCommandClass(Ca002t.class);
}
/**
* 파일업로드를 위한 빈 설정의 property
* destinationDir setter injection
* @param destinationDir
*/
public void setDestinationDir(String destinationDir) {
this.destinationDir = destinationDir;
}
/**
* FileService setter Injection
* @param fileService
*/
public void setFileService(FileService fileService) {
this.fileService = fileService;
}
public FileService getFileService() {
return this.fileService;
}
public void setBoardService(BoardService boardService) {
this.boardService = boardService;
}
public BoardService getBoardService() {
return this.boardService;
}
protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder)
throws ServletException {
binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor());
}
/* (non-Javadoc)
* @see org.springframework.web.servlet.mvc.AbstractCommandController#handle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.Object, org.springframework.validation.BindException)
*/
@Override
protected ModelAndView handle(HttpServletRequest request, HttpServletResponse response,
Object command, BindException errors)
throws Exception {
// TODO Auto-generated method stub
ModelAndView mav = new ModelAndView("common/file_search_popup_01");
String mode = StringUtil.null2void(request.getParameter("mode"));
String cntnId = StringUtil.null2void(request.getParameter("cntnId"));
String dcmtRgsrNo = StringUtil.null2void(request.getParameter("dcmtRgsrNo"));
String attachList = StringUtil.null2void(request.getParameter("attachList"));
UserSession userSession = (UserSession) WebUtils.getRequiredSessionAttribute(request, "userSession");
FileService fileService = (FileService) getFileService();
BoardService boardService = (BoardService) getBoardService();
ArrayList<Ca002t> attach = new ArrayList<Ca002t>();
Ca002t ts002t = null;
if (attachList != null && attachList != "") {
StringTokenizer files = new StringTokenizer(attachList, "^");
while (files.hasMoreTokens()) {
ts002t = new Ca002t();
StringTokenizer token = new StringTokenizer(files.nextToken(), "|");
while(token.hasMoreTokens()) {
ts002t.setSysFileName(token.nextToken());
ts002t.setOrgnFileName(token.nextToken());
attach.add(ts002t);
}
}
}
if (mode.equals("ADD")) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
MultipartFile file = multipartRequest.getFile("file");
String fileName = file.getOriginalFilename();
String sysFileName = GenSequenceNo.getFileRgsrNo(userSession.getEmpNo());
File destination = File.createTempFile(sysFileName, "", new File(destinationDir));
FileCopyUtils.copy(file.getInputStream(), new FileOutputStream(destination));
Ca002t fileVO = (Ca002t) command;
fileVO.setOrgnFileName(file.getOriginalFilename());
fileVO.setSysFileName(sysFileName);
fileVO.setFileSize(file.getSize());
fileVO.setFileData(file.getBytes());
fileService.addTempFileUpload(fileVO);
destination.delete();
attach.add(fileVO);
if (attachList.trim().equals("")) {
attachList = fileVO.getSysFileName() + "|" + fileVO.getOrgnFileName();
} else {
attachList = attachList + "^" + fileVO.getSysFileName() + "|" + fileVO.getOrgnFileName();
}
mav.addObject("mode", "ADD");
mav.addObject("attachFileList", attachList);
mav.addObject("attachList", attach);
} else if (mode.equals("DEL")) {
String delFile = StringUtil.null2void(request.getParameter("delFile"));
StringTokenizer token = new StringTokenizer(delFile, "|");
String orgnFileName = "";
String sysFileName = "";
while(token.hasMoreTokens()) {
sysFileName = token.nextToken();
orgnFileName = token.nextToken();
}
Ca002tExample example = new Ca002tExample();
Ca002tExample.Criteria c = example.createCriteria();
c.andSysFileNameEqualTo(sysFileName);
c.andOrgnFileNameEqualTo(orgnFileName);
fileService.removeTempFileUpload(example);
for (int i = 0; i < attach.size(); i++) {
Ca002t temp = (Ca002t) attach.get(i);
if (temp.getSysFileName().equals(sysFileName)) attach.remove(i);
}
attachList = "";
for (int i = 0; i < attach.size(); i++) {
Ca002t fileVO = (Ca002t) attach.get(i);
if (i == 0) {
attachList = fileVO.getSysFileName() + "|" + fileVO.getOrgnFileName();
} else {
attachList = attachList + "^" + fileVO.getSysFileName() + "|" + fileVO.getOrgnFileName();
}
}
mav.addObject("mode", "DEL");
mav.addObject("attachFileList", attachList);
mav.addObject("attachList", attach);
} else if (mode.equals("LIST")) {
// Temp 테이블에 첨부파일이 등록되어져 있는지 확인
int fileCnt = attach.size();
Ca002m attachFile = new Ca002m();
attachFile.setCntnId(cntnId);
attachFile.setDcmtRgsrNo(dcmtRgsrNo);
attachList = "";
for (int i = 0; i < fileCnt; i++) {
Ca002t tempFile = attach.get(i);
attachFile.setOrgnFileName(tempFile.getOrgnFileName());
attachFile.setSysFileName(tempFile.getSysFileName());
Ca002tExample example = new Ca002tExample();
Ca002tExample.Criteria criteria = example.createCriteria();
criteria.andSysFileNameEqualTo(tempFile.getSysFileName());
criteria.andOrgnFileNameEqualTo(tempFile.getOrgnFileName());
boolean check = fileService.findCheckTempFileUpload(example);
// Temp 테이블에 첨부파일이 없을 경우
if (!check) {
Ca002m result = boardService.findAttachFileInfo(attachFile);
Ca002t insTempFile = new Ca002t();
insTempFile.setOrgnFileName(result.getOrgnFileName());
insTempFile.setSysFileName(result.getSysFileName());
insTempFile.setFileSize(result.getFileSize());
insTempFile.setFileData(result.getFileData());
fileService.addTempFileUpload(insTempFile);
}
if (i == 0) {
attachList = tempFile.getSysFileName() + "|" + tempFile.getOrgnFileName();
} else {
attachList = attachList + "^" + tempFile.getSysFileName() + "|" + tempFile.getOrgnFileName();
}
}
mav.addObject("mode", "LIST");
mav.addObject("attachFileList", attachList);
mav.addObject("attachList", attach);
}
mav.addObject("cntnId", cntnId);
mav.addObject("dcmtRgsrNo", dcmtRgsrNo);
return mav;
}
}
2014년 4월 28일 월요일
팝업 창 중앙에 띄우기
브라우저의 팝업 창을 중앙으로 띄우기.
function windowOpenCenter(url, parm, width, height) {
var sw = screen.availWidth ;
var sh = screen.availHeight ;
px=(sw - width)/2 ;
py=(sh - height)/2 ;
var set = 'top=' + py + ',left=' + px ;
set += ',width=' + width + ',height=' + height + ',toolbar=0,resizable=1,status=0,scrollbars=1' ;
window.open (url + '?' + parm , '' , set) ;
}
2014년 4월 17일 목요일
Spring Framework에서 Interceptor 설정 방법
먼저 Interceptor 클래스를 생성
/**
*
*/
package sample;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.util.WebUtils;
import util.ApplicationConfigReader;
import util.UserSession;
/**
* @author 9791714
*
*/
public class LogonInterceptor implements HandlerInterceptor {
private static final Logger logger = LoggerFactory.getLogger(LogonInterceptor.class);
/**
* Controller 가 수행되기 전에 호출됩니다.
*/
@Override
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response,
Object handler) throws Exception {
logger.debug("LogonInterceptor start");
//세션정보를 확인한다.
UserSession userSession = (UserSession) WebUtils.getSessionAttribute(request, "userSession");
//세션정보를 확인해서 null일 경우, 로그인 페이지로 이동
if (userSession == null) {
String redirectUrl = ApplicationConfigReader.get("webAppRoot") + "/loginForm";
response.sendRedirect(redirectUrl);
return false;
}
logger.debug("LogonInterceptor end");
return true;
}
/**
* Controller의 메소드가 수행이 완료되고, View 를 호출하기 전에 호출됩니다.
*/
@Override
public void postHandle(HttpServletRequest request,
HttpServletResponse response,
Object handler,
ModelAndView modelAndView) throws Exception {
// Nothing to do
}
/**
* View 작업까지 완료된 후 Client에 응답하기 바로 전에 호출됩니다.
*/
@Override
public void afterCompletion(HttpServletRequest request,
HttpServletResponse response,
Object handler,
Exception ex) throws Exception {
if(logger.isDebugEnabled()) {
logger.debug("logonInterceptor를 종료합니다.");
}
}
}
/**
*
*/
package sample;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.util.WebUtils;
import util.ApplicationConfigReader;
import util.UserSession;
/**
* @author 9791714
*
*/
public class LogonInterceptor implements HandlerInterceptor {
private static final Logger logger = LoggerFactory.getLogger(LogonInterceptor.class);
/**
* Controller 가 수행되기 전에 호출됩니다.
*/
@Override
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response,
Object handler) throws Exception {
logger.debug("LogonInterceptor start");
//세션정보를 확인한다.
UserSession userSession = (UserSession) WebUtils.getSessionAttribute(request, "userSession");
//세션정보를 확인해서 null일 경우, 로그인 페이지로 이동
if (userSession == null) {
String redirectUrl = ApplicationConfigReader.get("webAppRoot") + "/loginForm";
response.sendRedirect(redirectUrl);
return false;
}
logger.debug("LogonInterceptor end");
return true;
}
/**
* Controller의 메소드가 수행이 완료되고, View 를 호출하기 전에 호출됩니다.
*/
@Override
public void postHandle(HttpServletRequest request,
HttpServletResponse response,
Object handler,
ModelAndView modelAndView) throws Exception {
// Nothing to do
}
/**
* View 작업까지 완료된 후 Client에 응답하기 바로 전에 호출됩니다.
*/
@Override
public void afterCompletion(HttpServletRequest request,
HttpServletResponse response,
Object handler,
Exception ex) throws Exception {
if(logger.isDebugEnabled()) {
logger.debug("logonInterceptor를 종료합니다.");
}
}
}
설정 파일에 Interceptor 설정
<mvc:interceptors>
<bean class="sample.LogonInterceptor"/>
</mvc:interceptors>
2014년 4월 10일 목요일
maven pom 파일
Spring Framework 3.1.4 환경에 맞는 maven 설정 파일
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.dsme</groupId>
<artifactId>Test</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<properties>
<java-version>1.6</java-version>
<org.springframework-version>3.1.4.RELEASE</org.springframework-version>
<org.aspectj-version>1.6.10</org.aspectj-version>
<org.slf4j-version>1.6.6</org.slf4j-version>
</properties>
<name>Test Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.2.3</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_2.5_spec</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.7.3</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.7.3</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
</dependencies>
<build>
<finalName>Test</finalName>
</build>
</project>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.dsme</groupId>
<artifactId>Test</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<properties>
<java-version>1.6</java-version>
<org.springframework-version>3.1.4.RELEASE</org.springframework-version>
<org.aspectj-version>1.6.10</org.aspectj-version>
<org.slf4j-version>1.6.6</org.slf4j-version>
</properties>
<name>Test Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-oxm</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>1.2.2</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.2.3</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-servlet_2.5_spec</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${org.springframework-version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.7.3</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.7.3</version>
</dependency>
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.1</version>
</dependency>
</dependencies>
<build>
<finalName>Test</finalName>
</build>
</project>
2014년 4월 8일 화요일
Spring Framework의 xml 설정 파일.
applicationContext.xml 파일은 /WEB-INF 폴더 아래에 있고, 나머지 설정 파일들은 classpath 내의 config 폴더에 위치.
database-context.xml
------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!-- bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>jdbc.namePool</value>
</property>
</bean-->
<context:component-scan base-package="test">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Service" />
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
p:driverClassName="${database.driver}"
p:url="${database.url}"
p:username="${database.username}" p:password="${database.password}" />
<!-- transaction manager, use JtaTransactionManager for global tx -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!-- enable component scanning (beware that this does not enable mapper scanning!) -->
<context:component-scan base-package="test.service" />
<!-- enable autowire -->
<context:annotation-config />
<!-- enable transaction demarcation with annotations -->
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />
<!-- define the SqlSessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="typeAliasesPackage" value="test.domain" />
<!-- property name="configLocation" value="springbook/learningtest/spring/mybatis/mybatis-config.xml" /-->
<!-- property name="mapperLocations" value="classpath:sqlmap/*-sqlmap.xml" /-->
</bean>
<!-- scan for mappers and let them be autowired -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="test.persistence" />
</bean>
<!--
<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="sqlSessionFactory" />
</bean>
-->
</beans>
common-context.xml
-----------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<!-- ========================= Properties DEFINITIONS =============================== -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:/application.properties</value>
</list>
</property>
</bean>
<!-- ========================= RESOURCE DEFINITIONS =============================== -->
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames">
<list>
<value>messages</value>
</list>
</property>
</bean>
<bean id="messageSourceAccessor" class="org.springframework.context.support.MessageSourceAccessor">
<constructor-arg>
<ref local="messageSource" />
</constructor-arg>
</bean>
</beans>
root-context.xml
----------------------------------------------------------------
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!-- Root Context: defines shared resources visible to all other web components -->
<!-- Enables the Spring MVC @Controller programming model -->
<mvc:annotation-driven />
<mvc:default-servlet-handler />
<mvc:interceptors> <mvc:interceptor> <mvc:mapping path="/*"/> <beans:bean id="checkInterceptor" class="com.test.interceptor.LogonInterceptor"/> </mvc:interceptor> </mvc:interceptors>
<context:component-scan base-package="test" />
<beans:bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<beans:property name="alwaysUseFullPath" value="true"/>
</beans:bean>
<beans:bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<beans:property name="alwaysUseFullPath" value="true"/>
</beans:bean>
</beans:beans>
applicationContext.xml
------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />
<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<beans:bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<beans:property name="maxUploadSize">
<beans:value>20000000</beans:value>
</beans:property>
<beans:property name="uploadTempDir" ref="uploadDirResource" />
</beans:bean>
<beans:bean id="uploadDirResource" class="org.springframework.core.io.FileSystemResource">
<beans:constructor-arg>
<beans:value>D:/Temp/fileUpload/</beans:value>
</beans:constructor-arg>
</beans:bean>
</beans:beans>
applicationContext.xml 파일은 /WEB-INF 폴더 아래에 있고, 나머지 설정 파일들은 classpath 내의 config 폴더에 위치.
database-context.xml
------------------------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<!-- bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>jdbc.namePool</value>
</property>
</bean-->
<context:component-scan base-package="test">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Service" />
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource"
p:driverClassName="${database.driver}"
p:url="${database.url}"
p:username="${database.username}" p:password="${database.password}" />
<!-- transaction manager, use JtaTransactionManager for global tx -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!-- enable component scanning (beware that this does not enable mapper scanning!) -->
<context:component-scan base-package="test.service" />
<!-- enable autowire -->
<context:annotation-config />
<!-- enable transaction demarcation with annotations -->
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />
<!-- define the SqlSessionFactory -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="typeAliasesPackage" value="test.domain" />
<!-- property name="configLocation" value="springbook/learningtest/spring/mybatis/mybatis-config.xml" /-->
<!-- property name="mapperLocations" value="classpath:sqlmap/*-sqlmap.xml" /-->
</bean>
<!-- scan for mappers and let them be autowired -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="test.persistence" />
</bean>
<!--
<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="sqlSessionFactory" />
</bean>
-->
</beans>
common-context.xml
-----------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
<!-- ========================= Properties DEFINITIONS =============================== -->
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:/application.properties</value>
</list>
</property>
</bean>
<!-- ========================= RESOURCE DEFINITIONS =============================== -->
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basenames">
<list>
<value>messages</value>
</list>
</property>
</bean>
<bean id="messageSourceAccessor" class="org.springframework.context.support.MessageSourceAccessor">
<constructor-arg>
<ref local="messageSource" />
</constructor-arg>
</bean>
</beans>
root-context.xml
----------------------------------------------------------------
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!-- Root Context: defines shared resources visible to all other web components -->
<!-- Enables the Spring MVC @Controller programming model -->
<mvc:annotation-driven />
<mvc:default-servlet-handler />
<mvc:interceptors> <mvc:interceptor> <mvc:mapping path="/*"/> <beans:bean id="checkInterceptor" class="com.test.interceptor.LogonInterceptor"/> </mvc:interceptor> </mvc:interceptors>
<context:component-scan base-package="test" />
<beans:bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<beans:property name="alwaysUseFullPath" value="true"/>
</beans:bean>
<beans:bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<beans:property name="alwaysUseFullPath" value="true"/>
</beans:bean>
</beans:beans>
applicationContext.xml
------------------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />
<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<beans:bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<beans:property name="maxUploadSize">
<beans:value>20000000</beans:value>
</beans:property>
<beans:property name="uploadTempDir" ref="uploadDirResource" />
</beans:bean>
<beans:bean id="uploadDirResource" class="org.springframework.core.io.FileSystemResource">
<beans:constructor-arg>
<beans:value>D:/Temp/fileUpload/</beans:value>
</beans:constructor-arg>
</beans:bean>
</beans:beans>
2014년 3월 9일 일요일
Eclipse 사용 도중 이러한 에러가 날 경우, workspace\.metadata 폴더에 있는 .log파일을 열어본다.
log 파일에 하기와 같은 오류가 있을 경우,
!ENTRY org.eclipse.ui.workbench 4 2 2014-03-10 10:25:38.545
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.ui.workbench".
!STACK 0
java.lang.NullPointerException
at org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper.getService(ServiceHelper.java:74)
at org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry.updateRoamingProfile(SimpleProfileRegistry.java:156)
at org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry.updateSelfProfile(SimpleProfileRegistry.java:147)
at org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry.getProfileMap(SimpleProfileRegistry.java:344)
at org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry.internalGetProfile(SimpleProfileRegistry.java:248)
at org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry.getProfile(SimpleProfileRegistry.java:178)
at org.eclipse.equinox.internal.p2.ui.sdk.scheduler.AutomaticUpdateScheduler.earlyStartup(AutomaticUpdateScheduler.java:88)
at org.eclipse.ui.internal.EarlyStartupRunnable.runEarlyStartup(EarlyStartupRunnable.java:87)
at org.eclipse.ui.internal.EarlyStartupRunnable.run(EarlyStartupRunnable.java:66)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.ui.internal.Workbench$55.run(Workbench.java:2551)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
이런 저런 설정들을 바꾸어 보았으나 도저히 잡히지가 않았다.
우연히 구글링을 하면서 발견한 팀.
workspace\.metadata\.plugins\org.eclipse.e4.workbench안의 xml파일을 삭제하니 정상적으로 잘 작동한다.
log 파일에 하기와 같은 오류가 있을 경우,
!ENTRY org.eclipse.ui.workbench 4 2 2014-03-10 10:25:38.545
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.ui.workbench".
!STACK 0
java.lang.NullPointerException
at org.eclipse.equinox.internal.p2.core.helpers.ServiceHelper.getService(ServiceHelper.java:74)
at org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry.updateRoamingProfile(SimpleProfileRegistry.java:156)
at org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry.updateSelfProfile(SimpleProfileRegistry.java:147)
at org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry.getProfileMap(SimpleProfileRegistry.java:344)
at org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry.internalGetProfile(SimpleProfileRegistry.java:248)
at org.eclipse.equinox.internal.p2.engine.SimpleProfileRegistry.getProfile(SimpleProfileRegistry.java:178)
at org.eclipse.equinox.internal.p2.ui.sdk.scheduler.AutomaticUpdateScheduler.earlyStartup(AutomaticUpdateScheduler.java:88)
at org.eclipse.ui.internal.EarlyStartupRunnable.runEarlyStartup(EarlyStartupRunnable.java:87)
at org.eclipse.ui.internal.EarlyStartupRunnable.run(EarlyStartupRunnable.java:66)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.ui.internal.Workbench$55.run(Workbench.java:2551)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
이런 저런 설정들을 바꾸어 보았으나 도저히 잡히지가 않았다.
우연히 구글링을 하면서 발견한 팀.
workspace\.metadata\.plugins\org.eclipse.e4.workbench안의 xml파일을 삭제하니 정상적으로 잘 작동한다.
피드 구독하기:
글 (Atom)