머리 뜯으며 개발/Spring Boot
.jsp .xml 등 배포 이후 리소스파일 수정을 위한 properties 설정
힘꿈망
2020. 8. 18. 13:36
실서버 배포 이후 유지보수를 할때,
90% 이상이 쿼리나 웹 단 쪽 수정이 대부분.
그럴때마다 새롭게 jar파일을 만들어서 배포 할순 없으니
WEB-INF 와 .xml 을 외부로 빼서 이후에 수정을 할 수 있겠끔 설정을 하는 것이 필요.
1. application.properties에서
spring.resource.static-locations = 리소스파일 경로
spring.datasource.config-location = DB config 파일 경로
를 설정 해준다.
2. DB config 파일에서 불러올 .xml 파일 경로 설정
3. jar 파일을 실행 시킬때 외부 properties 실행 옵션을 준다.
ex) nohup java -jar ______.jar --spring.config.location='내 properties'
- application.properties
1
2
3
4
5
6
7
8
9
10
11
|
# DB 설정
# 기존 환경 설정 방식
spring.datasource.config-location=classpath:/mybatis/HELP/SqlMapConfig.xml
# 내 설정 파일 위치 지정(url or file)
spring.datasource.config-location=file://'파일경로위치'/SqlMapConfig.xml
# Resource 설정
#WEB-INF 와 같은 resource 위치 지정 (url or file)
spring.resources.static-locations=file://'파일경로위치'
|
cs |
- SqlMapConfig.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<setting name="callSettersOnNulls" value="true"/>
</settings>
<mappers>
<!-- 기존 resource 형태 mapping -->
<mapper resource="mybatis/AMM/job.xml"></mapper>
<!-- url을 통한 file mapping -->
<mapper url="file://'파일경로위치'/job.xml"></mapper>
</mappers>
</configuration>
|
cs |
- 전체 형태