title: Spring Junit4 Testing error : no DataSource specified
body: <p>Hello I am a college student living in Korea.
  I've been studying the process and I'm getting an error during the unit testing (Junit) of the project I'm working on</p>
  
  <p>I tried Googleing for 3 days, but it did not work out. so, I need help.</p>
  
  <p>This works well for UserDaoTest. However, one method of BoardDaoTest is not tested. I attach my source code here.</p>
  
  <ol>
  <li><p>JdbcTemplate.java</p>
  
  <pre><code> public class JdbcTemplate extends JdbcDaoSupport {
        private static final Logger logger =  LoggerFactory.getLogger(JdbcTemplate.class);
  
        public static Connection conn;
        public PreparedStatement pstmt;
        public PreparedStatement pstmt2;
        public ResultSet rs;
  
        @PostConstruct
        public void initialize() {
          DataSource ds = getDataSource();
          logger.info("get Data Source success!");
          conn = DataSourceUtils.getConnection(ds);
          logger.info("Conn = " + conn);
          logger.info("database initialized success!");
        } { ... }
  </code></pre></li>
  <li><p>applicationContext.xml</p>
  
  <pre><code>&lt;context:annotation-config /&gt;
  
  &lt;context:property-placeholder location="classpath*:application-properties.xml" /&gt;
  
  &lt;bean id="applicationContextProvider" class="viser.service.ApplicationContextProvider" /&gt;
  
  &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
      p:driverClassName="${database.driverClassName}" 
      p:url="${database.url}"
      p:username="${database.username}" 
      p:password="${database.password}" 
  /&gt;
  
  &lt;bean id="jdbcTemplate" class="viser.service.support.jdbc.JdbcTemplate"
      p:dataSource-ref="dataSource"
  /&gt;
  
  &lt;bean id="userDAO" class="viser.dao.user.UserDAO"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
  &lt;/bean&gt;
  
  &lt;bean id="boardDAO" class="viser.dao.board.BoardDAO"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p></p></li>
  <li><p>UserDAOTest.java ( Successful testing )</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration("classpath:/applicationContext.xml")
  public class UserDAOTest {
  
    @Autowired
    private UserDAO userDAO;
    private User user;
  
    @Before
    public void setUp() {
      user = UserTest.TEST_USER;
    }
  
    @After
    public void returns() throws SQLException {
      userDAO.removeUser(user.getUserId());
    }
  
    @Test
    public void crud() throws Exception {
     { ... }
    }
  
    @Test
    public void getWhenNotExsitUser() throws Exception {
     { ... }
    }
  </code></pre></li>
  <li><p>BoardDAOTest.java (crud() -> success, getList() -> fail)</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration("classpath:/applicationContext.xml")
  public class BoardDAOTest {
  private static final Logger logger = LoggerFactory.getLogger(BoardDAOTest.class);
  
   public static Board TEST_BOARD = new Board("TEST_BOARD", 
  `ProjectDAOTest.TEST_PROJECT.getProjectName());`
            @Autowired
            private BoardDAO boardDAO;
            private ProjectDAO projectDAO;
  
            @Before
            public void setup() throws SQLException {
              boardDAO = new BoardDAO();
              projectDAO = new ProjectDAO();
              projectDAO.addProject(ProjectDAOTest.TEST_PROJECT);
            }
  
            @After
            public void returns() throws SQLException {
              projectDAO.removeProject(ProjectDAOTest.TEST_PROJECT.getProjectName());
            }
  
            @Test
            public void crud() throws SQLException {
              {...}
            }
  
            @Test
            public void getList() throws SQLException {
              logger.debug("list : {}", boardDAO.getBoardList(ProjectDAOTest.TEST_PROJECT.getProjectName()));  assertNotNull(boardDAO.getBoardList(ProjectDAOTest.TEST_PROJECT.getProjectName()));
        }
  </code></pre></li>
  </ol>
  
  <p><a href="https://i.stack.imgur.com/X7aGg.png" rel="nofollow noreferrer"> (errorImageFile) </a></p>