728x90
반응형
프로젝트 설정을 해보자.
Spring 보다 설정이 간단하다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 |
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableScheduling
@MapperScan("com.webha.*.dao")
public class WebhaApplication {
public static void main(String[] args) {
SpringApplication.run(WebhaApplication.class, args);
}
}
|
@SpringBootApplication 은 스프링 부트 메인 메서드 가동을 위한 어노테이션이다.
@EnableScheduling 은 배치 설정을 위한것이다. 아래 설정으로 끝났다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52 |
import java.util.concurrent.atomic.AtomicInteger;
import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.StopWatch;
import com.webha.batch.dao.BatchDao;
@Component
public class WebhaBatch {
Logger logger = LoggerFactory.getLogger(this.getClass());
private AtomicInteger loopCounter = new AtomicInteger();
@Autowired
private StopWatch watch;
@Autowired
private BatchDao batchDao;
@Value("${spring.task.name}")
private String taskNamePrefix;
@Value("${spring.timerName}")
private String timerName;
@PostConstruct
public void init() {
logger.info("{} init", timerName);
watch.start();
}
@Scheduled(fixedDelayString = "${spring.task.fixedDelay}")
public void tick() throws InterruptedException{
watch.stop();
logger.info("serverTime ::::: " + batchDao.getServerTime());
String taskName = taskNamePrefix + "-" + String.valueOf(loopCounter.getAndIncrement());
watch.start(taskName);
}
@Bean
public StopWatch watch() {
return new StopWatch();
}
} |
@MapperScan("com.webha.*.dao") 은 mybatis 설정이다.
뒤에서 자세히 글 남기겠습니다.
앞서 build.gradle 에서 사용한 라이브러리중에 log4jdbc 는 DriverSpy 를 위한것
1
2 |
log4jdbc.spylogdelegator.name = net.sf.log4jdbc.log.slf4j.Slf4jSpyLogDelegator
log4jdbc.dump.sql.maxlinelength=0 |
아래는 application.yml 참고용이다. (#은 주석이다)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55 |
server:
port: 7000
error:
path: /error/error.ftl
include-stacktrace: always #never
whitelabel.enabled: true
logging:
level:
org:
springframework:
web: INFO #DEBUG
pattern:
console: '%d{yyyy-MM-dd HH:mm:ss} - %msg%n'
file: '%d{yyyy-MM-dd HH:mm:ss} [%thread] %-1level %logger{10} - %msg%n'
spring:
profiles:
active: batchDev
task:
fixedDelay: 148000000
name: batchDevTask
mail:
host: smtp.gmail.com
username: *****@gmail.com
password: tznqw*****bfngwat
port: 587
properties:
mail:
smtp:
auth: true
starttls:
enable: true
required: true
timerName: serverTimer
datasource:
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
url: jdbc:log4jdbc:oracle:thin:@localhost:1521:xe
username: ******
password: ******
#주석 url: jdbc:log4jdbc:oracle:thin:@00.0.00.000:1521:icdb
#주석 username: ******
#주석 password: ******
session:
store-type: none
mybatis:
mapper-locations: classpath:mapper/*/*.xml
configuration:
lazyLoadingEnabled: true
aggressiveLazyLoading: false
mapUnderscoreToCamelCase: true
multipart:
enabled: true
location: D:\upload\
max-file-size: 100Mb
max-request-size: 100Mb
file-size-threshold: 10Mb |
스프링 빌드시 올라가는 배너를 banner.txt 로 대체할 수 있다.
[출처] 4. Spring Boot - yml 설정 (웹의 하루) |작성자 뺑이
728x90
반응형
'SPRINGBOOT > 노하우정보' 카테고리의 다른 글
7. Spring Boot - Mapper (0) | 2017.05.29 |
---|---|
6. Spring Boot - Template Engine (0) | 2017.05.29 |
5. Spring Boot - Mybatis 설정 (0) | 2017.05.29 |
3. Spring Boot - Gradle 설정 (0) | 2017.05.29 |
2. Spring Boot - 프로젝트 생성 (0) | 2017.05.29 |
1. Spring Boot - 이클립스 세팅 (0) | 2017.05.29 |