RestTemplate 생성 시 Timeout 설정 방법.


// Connection Timeout 10초, ReadTimeout 10초 설정.

private RestTemplate getRestTemplate() {
HttpComponentsClientHttpRequestFactory factory 

= new HttpComponentsClientHttpRequestFactory();
factory.setConnectTimeout(10*1000);
factory.setReadTimeout(10*1000);
RestTemplate restTemplate = new RestTemplate(factory);
return restTemplate;
}



Posted by 무세1
,

tomcat console 로그에서 한글 깨짐 현상 발생.


톰켓 기동시 file encoding option 추가하니 해결.


set "JAVA_OPTS=%JAVA_OPTS% -Dfile.encoding=UTF8"


'linux' 카테고리의 다른 글

grep binary  (0) 2018.08.31
vi에 paste시 생기는 들여쓰기 자동현상 OFF  (0) 2018.01.15
apache에서 tomcat 설정.  (0) 2016.03.29
curl 이용하기  (0) 2015.09.03
리눅스 file 사이즈 0 으로 만들기  (0) 2015.07.31
Posted by 무세1
,

맥북 scala 설치

scala 2016. 5. 1. 13:44

brew를 이용해서 설치 하면 됨.


$ brew install scala

==> Downloading https://homebrew.bintray.com/bottles/scala-2.11.8.yosemite.bottl

######################################################################## 100.0%

==> Pouring scala-2.11.8.yosemite.bottle.tar.gz

==> Caveats

To use with IntelliJ, set the Scala home to:

  /usr/local/opt/scala/idea


Bash completion has been installed to:

  /usr/local/etc/bash_completion.d

==> Summary

🍺  /usr/local/Cellar/scala/2.11.8: 51 files, 30.9M


$ brew install sbt

==> Downloading https://dl.bintray.com/sbt/native-packages/sbt/0.13.11/sbt-0.13.

######################################################################## 100.0%

==> Caveats

You can use $SBT_OPTS to pass additional JVM options to SBT:

   SBT_OPTS="-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256M"


This formula is now using the standard typesafe sbt launcher script.

Project specific options should be placed in .sbtopts in the root of your project.

Global settings should be placed in /usr/local/etc/sbtopts

==> Summary

🍺  /usr/local/Cellar/sbt/0.13.11: 5 files, 1.2M, built in 3 seconds



Posted by 무세1
,

log4j 설정

java 2016. 4. 6. 11:26

간단한 배치 프로그램을 만들었는데... log를 찍기 위해 log4j를 maven dependency에 추가 했다.


batch.jar를 만들어서 콘솔에서 java -jar batch.jar 로 실행을 했다.


java -jar batch.jar


log4j:WARN No appenders could be found for logger (com.BatchMain).

log4j:WARN No appenders could be found for logger.


빨간색의 오류가 발생됬다. 

log4j.properties 파일은 jar파일에 포함되어 있다.


해결책은  -Dlog4j.configuration 옵션을 주면 해결이 된다.


> java -Dlog4j.configuration=properties/log4j.properties -jar batch.jar


jar에 묶여있지 않고, file을 참조 하려면

> java -Dlog4j.configuration=file:/root/properties/log4j.properties -jar batch.jar


'java' 카테고리의 다른 글

RestTemplate Urlcoding 삽질기..  (0) 2016.07.08
Spring RestTemplate timeout 설정  (0) 2016.05.30
JPA 사용시 특정 컬럼만 UPDATE 하는 방법..  (0) 2016.04.01
서버 Hostname 가져오기..  (0) 2016.03.09
Java 8 날짜 정리  (0) 2015.12.17
Posted by 무세1
,

기본적으로 JPA를 사용하면 update시 PK를 제외한 전체 컬럼을 업데이트 한다.


Oracle의 경우 테이블 파티션을 나누는데, 

파티션의 키가 되는 컬럼을 업데이트 할때 partition move가 되는 경우 오류가 발생한다.


개발DB는 보통 파티션을 하지 않거나, 파티션 무브를 허용하지만, 

운영DB는 보통 파티션 무브를 허용하지 않는다고 한다... 


운영파티션무브를 허용하거나, 

또는

Domain에 다음과 같이 어노테이션을 추가하여 변경된 컬럼만 업데이트 하도록 하여 해결하면 된다.

@org.hibernate.annotations.DynamicUpdate



@Entity

@org.hibernate.annotations.DynamicUpdate

public class Member {

@id

private long id;

private String name;

..

..

}


'java' 카테고리의 다른 글

Spring RestTemplate timeout 설정  (0) 2016.05.30
log4j 설정  (0) 2016.04.06
서버 Hostname 가져오기..  (0) 2016.03.09
Java 8 날짜 정리  (0) 2015.12.17
java.sql.SQLRecoverableException: IO Error: Connection reset 오류 해결  (0) 2015.11.30
Posted by 무세1
,

apache에서 tomcat 설정.

linux 2016. 3. 29. 16:09

Apache에서 특정 url만 tomcat으로 넘기고 싶을때...  conf/extra/httpd-vhosts.conf를 열고 수정하면 된다.


<VirtualHost _default_:80>

ServerName _default_:80

DocumentRoot ...

....


JkMount /*.jsp Tomcat

JkMount /*.do Tomcat

</VirtualHost>



*.jsp, *.do URL을 톰캣으로 보내라는 설정이다.


특정 URL을 톰캣으로 보내고 싶지 않을때는, JkUnMount를 쓰면 된다.


'linux' 카테고리의 다른 글

vi에 paste시 생기는 들여쓰기 자동현상 OFF  (0) 2018.01.15
Tomcat console log UTF-8 설정.  (0) 2016.05.27
curl 이용하기  (0) 2015.09.03
리눅스 file 사이즈 0 으로 만들기  (0) 2015.07.31
리눅스 find cp 혼합  (0) 2015.07.29
Posted by 무세1
,

maven project를 만들었다.


기존에 tomcat에..  classs 와..  js, css, jpg, html을 모두 배포 했다.


그런데..  web resource(js, css, jpg, html 등)를 apache 웹서버에 배포를 해야 했다. 


그래서web resource를 따로 분리 해야 했다..  


그래서 maven-assembly-plugin을 사용해서 분리했다.


pom.xml에 plugins 다음을 추가한다.

<build>
<plugins>
<!-- 정적파일 ZIP로 만드는 플러그인 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<descriptors>
<descriptor>assembly_webStaticFile.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>bin</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>



assembly_webStaticFile.xml 을 다음과 같이 만들어 준다.

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>bin</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>src/main/webapp</directory>
<filtered>false</filtered>
<outputDirectory>/</outputDirectory>
<excludes>
<exclude>**/WEB-INF/**</exclude>
<exclude>**/*.jsp</exclude>
</excludes>
</fileSet>
</fileSets>

</assembly>


터미널에서 다음과 같이 실행하면 web resource 파일만 따로 만든다.

mvn assembly:single



세세한 사항은 아래 사이트에 들어가면 알 수 있다.

http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html



'maven' 카테고리의 다른 글

maven build시 test 코드 스킵  (0) 2015.12.16
Posted by 무세1
,

맥북 화면캡쳐

맥북 2016. 3. 15. 16:00


Mac OS에서 화면 캡쳐 방법.

1. 모니터 전체화면 캡쳐: Shift + Command + 3

2. 마우스 드래그 캡쳐 : Shift + Commant + 4

3. 선택된 윈도우 캡쳐 : Shift +Command + 4 + Space


화면을 캡쳐하면 바탕화면에 캡쳐된 이미지 파일이 생성된다.

Posted by 무세1
,


서버에 Hostname이 설정이 되어 있다면 아래와 같이 불러올 수 있다.

System.getenv("HOSTNAME");


설정이 되어 있지 않다면....

public static String getHostName(){
String hostname = System.getenv("HOSTNAME");
if(hostname != null) return hostname;

String lineStr = "";
try {
Process process = Runtime.getRuntime().exec("hostname");
BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream()));
while((lineStr = br.readLine()) != null ){
hostname = lineStr;
}
}catch (IOException e) {
e.printStackTrace();
hostname = "";
}
return hostname;
}


Posted by 무세1
,

맥북에서 블루투스 기기(키보드, 마우스 등)가 갑자기 연결이 잘 안될때...


Ctrl+Space를 눌러 Active Monitor.app 실행 후 blued 프로세스를 종료하면 블루투스 프로세스가 재실행 되면서 연결이 잘 됨.


터미널에서 블루투스를 죽이는 방법도 있음.


sudo killall -HUP blued


'맥북' 카테고리의 다른 글

맥북 패러럴즈 한영전환키 변경 ( Command+Space )  (0) 2016.06.15
맥북 화면캡쳐  (0) 2016.03.15
맥북에서 ftp 서버 열기  (0) 2015.04.15
mac에서 java_home 설정  (0) 2015.03.09
맥북에서 hosts 파일 변경  (0) 2014.12.05
Posted by 무세1
,