ArticleService.java
package com.linuxidc.serviceImpl; import java.util.List; import javax.annotation.Resource; import org.springframework.stereotype.Service; import com.linuxidc.dao.ArticleMapper; import com.linuxidc.dao.NewsMapper; import com.linuxidc.model.Article; import com.linuxidc.model.News; import com.linuxidc.service.IArticleService; import com.linuxidc.service.INewsService; @Service("articleService") public class ArticleServiceImpl implements IArticleService{ @Resource private ArticleMapper articleMapper; @Override public List<Article> getAll() { return this.articleMapper.getAll(); } @Override public List<Article> getTitleList(String tag) { // TODO Auto-generated method stub return this.articleMapper.getTitleList(tag); } }Junit测试类(不算在结构内,实际应该是页面访问controller)
package com.linuxidc.test; import java.util.List; import javax.annotation.Resource; import org.apache.log4j.Logger; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.alibaba.fastjson.JSON; import com.linuxidc.model.News; import com.linuxidc.service.INewsService; @RunWith(SpringJUnit4ClassRunner.class)//琛ㄧず缁ф壙浜哠pringJUnit4ClassRunner绫� @ContextConfiguration(locations = {"classpath:spring-mybatis.xml"}) public class Test{ private static Logger logger = Logger.getLogger(TestMyBatis.class); @Resource private INewsService newsService = null; @Test public void test1() { List<News> newsList = newsService.getAllNews(); // System.out.println(user.getUserName()); // logger.info("鍊硷細"+user.getUserName()); logger.info(JSON.toJSONStringWithDateFormat(newsList,"MM-dd:HH:mm:ss")); } }jdbc配置文件
log4j配置文件
Spring与SpringMvc整合的配置文件
Spring与mybatis整合的配置文件