Spring 기반 웹 프로그래밍강의 중 질문이 있습니다.

2017-02-23 19:27

안녕하세요!! ㅎㅎ

여기다가 질문을 올려도...되는지 모르겠네요.... 저는 Spring 기반 웹프로그래밍 강의를 하나씩 따라가면서 공부하고있는 spring 왕초보 이구요... 따라하다가 질문이 있어..질문 드립니다.. "DB initialize & UserDao 구현" 을 듣던중 아래 소스를 코딩후

package net.slipp.dao.users;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:/applicationContext.xml")
public class UserDaoTest {

	private static final Logger log = LoggerFactory.getLogger(UserDaoTest.class);
	@Autowired
	private UserDao userDao;

	@Test
	public void findById() {
		User user = userDao.findById("shchlrdh");
		log.debug("User : {} ", user);

	}

}

부분 Junit 테스트 실행시 에러는 나지 않지만.. 로그 부분이 출력되지 않습니다.

Junit 실행시 콘솔내용은 아래와같습니다.

2월 23, 2017 7:20:11 오후 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions 정보: Loading XML bean definitions from class path resource [applicationContext.xml] 2월 23, 2017 7:20:11 오후 org.springframework.context.support.AbstractApplicationContext prepareRefresh 정보: Refreshing org.springframework.context.support.GenericApplicationContext@6ee52dcd: startup date [Thu Feb 23 19:20:11 KST 2017]; root of context hierarchy 2월 23, 2017 7:20:11 오후 org.springframework.core.io.support.PropertiesLoaderSupport loadProperties 정보: Loading properties file from URL [file:/D:/lshWorkspace/lshSpring/webapp/WEB-INF/classes/application-properties.xml] 2월 23, 2017 7:20:11 오후 org.springframework.jdbc.datasource.init.ScriptUtils executeSqlScript 정보: Executing SQL script from class path resource [slipp.sql] 2월 23, 2017 7:20:11 오후 org.springframework.jdbc.datasource.init.ScriptUtils executeSqlScript 정보: Executed SQL script from class path resource [slipp.sql] in 9 ms. 2월 23, 2017 7:20:11 오후 org.springframework.context.support.AbstractApplicationContext doClose 정보: Closing org.springframework.context.support.GenericApplicationContext@6ee52dcd: startup date [Thu Feb 23 19:20:11 KST 2017]; root of context hierarchy

=================================================================================

앞전 강의의 내용중 로그백 설정 후 로그 출력시 그부분에선 로그가 잘찍혔거든요... org.springframework.context.support.AbstractApplicationContext doClose 이부분의 문제인듯한데... 혹시 도움을 받을수 있을까요?.. 감사합니다..

5개의 의견 from SLiPP

2017-02-24 15:59

테스트 코드라고해서 특별히 다른 점은 없습니다. logback.xml에서 패키지별 로그 레벨 설정한 부분이 net.slipp과 같이 되어 있는지 확인해 보시기 바랍니다. 현재 테스트 코드의 패키지가 net.slipp으로 시작하네요.

만약 production code가 다른 패키지를 사용한다면 수정했을 수도 있습니다.

그래도 안된다면 logback.xml 파일 설정을 첨부해 주세요.

의견 추가하기

연관태그

← 목록으로