티스토리 뷰

http://seongilman.tistory.com/27



#.properties -> .xml로 변경하는 작업을 진행하였다.

#기존 <context:property-placeholder location="classpath:application.properties"/>는 삭제하고

<util:properties id="prop" location="classpath:properties.xml"/>

을 추가해서 value="#{prop['jdbc.driverClassName']}"와 같이 작성하였다.



#controller에서는 다음과 같이 사용


@Value("#{prop['test']}")
private String value;
@Autowired
private Properties prop;


# view(jsp)에서도 taglib를 통해서 사용가능한데

현재 프로젝트에서는 thymeleaf로 인해 사용불가능한 상태이다(-ㅅ-)... 사용가능하도록 설정을 변경하는 방법을 찾는 등 대안이 필요

레퍼런스는 상단의 사이트로 가볼 것




#xml 설정은 다음과 같다.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<comment>설명</comment>
<entry key="jdbc.driverClassName">com.mysql.jdbc.Driver</entry>
<entry key="jdbc.url">jdbc:mysql://xxx.xxx.xxx.xx:13306/db</entry>
<entry key="jdbc.username">user</entry>
<entry key="jdbc.password">password</entry>
<entry key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</entry>
<entry key="hibernate.show_sql">true</entry>
<entry key="hibernate.format_sql">true</entry>
<entry key="test">testValue</entry>
</properties>






댓글
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/04   »
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
글 보관함