[eclipse] 외부 에디터 사용할때 새로고침 자동으로 설정

화면쪽 작업을 할 때, 이클립스 에디터 말고 다른 에디터를 사용하고 싶다. 하지만 다른 에디터에서 저장을 해도 화면에 바로 적용이 안되고 이클립스에서 Refresh를 해줘야 하는 불편함이 있다. 그래서 찾아보니 Refresh 안해도 되게 하는 설정이 있다.

Eclipse 메뉴에서 Window > Preferences 선택하면 창이 뜬다.
그리고 General > Workspace 페이지로 가서 Refresh using native hooks or polling 설정을 체크해 주면 된다.

이것을 설정하면, 파일 업로드를 해도 Refresh를 해줘야 했었는데 Refresh 안해도 될 것 같다.

참고 : http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Ftasks%2Ftasks-52.htm

여러개의 Spring xml 설정파일, ApplicationContext는 몇개인가

보통 스프링 프로젝트를 만들 때 xml 기반으로 ApplicationContext를 생성하는 경우가 많다. 그리고 스프링 설정파일들도 ContextLoaderListener 라는 리스너에 여러개 등록할 수 있는데, 과연 이 경우에 컨텍스트가 여러개 생셩되는지, 하나의 컨텍스트가 생성되는 지 궁금했다. 

결론부터 말하자면 리스너에 아무리 많은 xml 파일들을 등록해도 하나의 ApplicationContext만 올라간다. 

아래 예제에서는 bean을 생성해준 컨텍스트 정보를 알 수 있도록 ApplicationContextAware를 구현한 클래스를 양쪽 xml에 등록하고 컨텍스트 정보를 출력해서 비교하였다.


web.xml


<context-param>

    <param-name>contextConfigLocation</param-name>

    <param-value>

    classpath:spring/application-context.xml

    classpath:spring/spring-security.xml

    </param-value>

</context-param>

application-context.xml


<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:context="http://www.springframework.org/schema/context"

xsi:schemaLocation="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">

    <context:component-scan base-package="com.tistory"></context:component-scan>

    <bean class="com.tistory.jekalmin.common.ApplicationContextHolder"/>

</beans>


spring-security.xml


<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xmlns:context="http://www.springframework.org/schema/context"

xsi:schemaLocation="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">

    

    <bean class="com.tistory.jekalmin.common.ApplicationContextHolder"/>


</beans>


ApplicationContextHolder.java


package com.tistory.jekalmin.common;


import org.springframework.beans.BeansException;

import org.springframework.context.ApplicationContext;

import org.springframework.context.ApplicationContextAware;


public class ApplicationContextHolder implements ApplicationContextAware{

@Override

public void setApplicationContext(ApplicationContext ctx)

throws BeansException {

System.out.println("applicationContext : " + ctx);

System.out.println("applicationContext hashCode : " + ctx.hashCode());

}


}


결과는 다음과 같다.


applicationContext : Root WebApplicationContext: startup date [Tue Sep 30 10:27:17 EDT 2014]; root of context hierarchy

applicationContext hashCode : 12545140

applicationContext : Root WebApplicationContext: startup date [Tue Sep 30 10:27:17 EDT 2014]; root of context hierarchy

applicationContext hashCode : 12545140





두개의 다른 xml에서 ApplicationContextAware를 구현한 클래스를 등록하고 hashCode를 출력하였는데, 같은 객체임을 알 수 있다.