Skip to content

Commit cd34e91

Browse files
author
冯周
committed
log4j
1 parent 0cf15b9 commit cd34e91

File tree

5 files changed

+46
-1
lines changed

5 files changed

+46
-1
lines changed

spitter-persistence-mybatis/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@
7272
<version>2.8.0</version>
7373
</dependency>
7474

75+
<dependency>
76+
<groupId>log4j</groupId>
77+
<artifactId>log4j</artifactId>
78+
<version>1.2.12</version>
79+
</dependency>
80+
7581
<dependency>
7682
<groupId>junit</groupId>
7783
<artifactId>junit</artifactId>

spitter-persistence-mybatis/spitter-persistence-mybatis.iml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.8.0" level="project" />
3333
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.8.0" level="project" />
3434
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.8.0" level="project" />
35+
<orderEntry type="library" name="Maven: log4j:log4j:1.2.12" level="project" />
3536
<orderEntry type="library" name="Maven: junit:junit:4.11" level="project" />
3637
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
3738
</component>

spitter-persistence-mybatis/src/main/java/com/vonzhou/spitter/Main.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.vonzhou.spitter.domain.Spitter;
44
import com.vonzhou.spitter.service.SpitterService;
5+
import com.vonzhou.spitter.service.SpitterService2;
56
import org.springframework.context.ApplicationContext;
67
import org.springframework.context.support.ClassPathXmlApplicationContext;
78

@@ -17,7 +18,8 @@ public static void main(String[] args) {
1718
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
1819
//JdbcSpitterDao dao = (JdbcSpitterDao)context.getBean("jdbcSpitterDao");
1920

20-
SpitterService spitterService = (SpitterService) context.getBean("spitterService");
21+
// SpitterService spitterService = (SpitterService) context.getBean("spitterService");
22+
SpitterService2 spitterService = (SpitterService2) context.getBean("spitterService2");
2123

2224

2325
Spitter s = new Spitter();
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.vonzhou.spitter.service;
2+
3+
import com.vonzhou.spitter.domain.Spitter;
4+
import com.vonzhou.spitter.mappers.SpitterMapper;
5+
import org.mybatis.spring.SqlSessionTemplate;
6+
import org.springframework.beans.factory.annotation.Autowired;
7+
import org.springframework.stereotype.Service;
8+
import org.springframework.transaction.annotation.Transactional;
9+
10+
import java.util.List;
11+
12+
/**
13+
* Created by vonzhou on 16/7/12.
14+
*/
15+
@Service(value = "spitterService2")
16+
@Transactional
17+
public class SpitterService2 {
18+
19+
@Autowired
20+
private SqlSessionTemplate sqlSessionTemplate;
21+
22+
public List<Spitter> findAllSpitters() {
23+
SpitterMapper spitterMapper = sqlSessionTemplate.getMapper(SpitterMapper.class);
24+
return spitterMapper.findAllSpitters();
25+
}
26+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
### set log levels - for more verbose logging change 'info' to 'debug' ###
2+
log4j.rootLogger =info, stdout
3+
4+
### direct log messages to stdout ###
5+
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
6+
log4j.appender.stdout.Target=System.out
7+
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
8+
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} %5p %c{1}:%L - %m%n
9+
10+
#log4j.logger.com.vonzhou.spitter.mappers.SpitterMapper=TRACE

0 commit comments

Comments
 (0)