반응형

2017/09/19 - [java] - spring boot - @Scheduled Test


@Scheduled 의 반복동작까지 그대로 테스트 하고 싶다면 위의 글처럼 하면 됩니다.


하지만 @Scheduled 가 걸린 함수를 기능 테스트만 하고 싶다면 조금 더 간편한 방법이 있습니다.


@EnableScheduling 을 선택적으로 사용하는 방법입니다.


@Scheduled 는 @EnableScheduling가 사전에 정의 되어야만 실행되도록 되어있습니다.


보통 @SpringBootApplication 가 정의된 Main Class에 @EnableScheduling 도 통으로 같이 설정해서 사용하는데,


Main Class에서 @EnableScheduling 을 제거하고 아래와 같은 @Configuration 클래스를 하나 추가해 @Profile을 통해 선택적으로  @Scheduled 함수들의 스케쥴링 여부를 결정할 수 있습니다.


@Profile("!test")
@Configuration
@EnableScheduling
public class SchedulingConfiguration {
 
}



@Profile("!test") 은 의미는 test 프로파일 active 되지 않았을 때 해당 설정을 적용하라는 뜻 입니다.


test 프로파일을 active 하려면 java 실행시 VMArguments 에 아래와 같이 설정하거나, 


-Dspring.profiles.active="test"


application.properties에 아래처럼 적용하면 됩니다.


spring.profiles.active=test


반응형
반응형
1. Generation KeyStore
[jeus@HOST keystore]$ keytool -genkey -alias ssltest -keyalg RSA -validity 365 -keystore /home/jeus/jeus6/config/HOST/keystore/keystore
Enter keystore password: tmaxtest
Re-enter new password: tmaxtest
What is your first and last name?
  [Unknown]:  tmax
What is the name of your organizational unit?
  [Unknown]:  tmax
What is the name of your organization?
  [Unknown]:  tmax
What is the name of your City or Locality?
  [Unknown]:  tmax
What is the name of your State or Province?
  [Unknown]:  tmax
What is the two-letter country code for this unit?
  [Unknown]:  KR
Is CN=tmax, OU=tmax, O=tmax, L=tmax, ST=tmax, C=KR correct?
  [no]:  y
 
Enter key password for <ssltest>
        (RETURN if same as keystore password): tmaxtest
Re-enter new password: tmaxtest
 
2. CER 인증서 생성
[jeus@HOST keystore]$  keytool -export -alias ssltest -keystore /home/jeus/jeus6/config/HOST/keystore/keystore -rfc -file jeusssl.cer
Enter keystore password: tmaxtest
Certificate stored in file <jeusssl.cer>
 
3. Truststore 생성
[jeus@HOST keystore]$  keytool -export -alias ssltest -keystore /home/jeus/jeus6/config/HOST/keystore/keystore -rfc -file jeusssl.cer
Enter keystore password: tmaxtest
Certificate stored in file <jeusssl.cer>
[jeus@HOST keystore]$ keytool -import -alias ssltestcert -file jeusssl.cer -keystore /home/jeus/jeus6/config/HOST/keystore/truststore
Enter keystore password:
Re-enter new password:
Owner: CN=tmax, OU=tmax, O=tmax, L=tmax, ST=tmax, C=KR
Issuer: CN=tmax, OU=tmax, O=tmax, L=tmax, ST=tmax, C=KR
Serial number: 378efbca
Valid from: Mon Dec 03 19:50:44 KST 2018 until: Tue Dec 03 19:50:44 KST 2019
Certificate fingerprints:
         MD5:  5E:9C:84:80:D4:E3:8B:E7:78:D4:50:98:E5:C7:DF:8F
         SHA1: EF:09:C2:37:C5:78:17:58:A9:08:A5:6A:47:B3:16:35:41:1B:6D:3A
         SHA256: 1F:62:D5:6A:D0:39:97:05:92:22:19:52:18:9C:3B:2A:A0:C9:B5:C3:B9:BC:8D:7F:BB:F5:02:B6:E6:1D:C1:D3
         Signature algorithm name: SHA256withRSA
         Version: 3
 
Extensions:
 
#1: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
000081 3E 80 9D CB 10 34 DA   33 D0 F7 C7 F6 58 B5 70  .>....4.3....X.p
0010: 3C B9 E0 A6                                        <...
]
]
 
Trust this certificate? [no]:  y
Certificate was added to keystore
 
4. WEBMain.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-container xmlns="http://www.tmaxsoft.com/xml/ns/jeus" version="6.0" xmlns:ns2="http://java.sun.com/xml/ns/javaee" xmlns:ns3="http://java.sun.com/xml/ns/persistence">
  <context-group>
    <group-name>MyGroup</group-name>
    <webserver-connection>
      <http-listener>
        <listener-id>http1</listener-id>
        <port>8088</port>
        <thread-pool>
          <min>10</min>
          <max>20</max>
          <step>1</step>
          <max-wait-queue>4</max-wait-queue>
        </thread-pool>
      </http-listener>
      <http-listener>
        <listener-id>http-ssl</listener-id>
        <port>443</port>
        <thread-pool>
          <min>10</min>
          <max>20</max>
          <step>1</step>
          <max-wait-queue>4</max-wait-queue>
        </thread-pool>
        <scheme>https</scheme>
        <ssl-config>
          <enable-secure>true</enable-secure>
          <keystore-file>/home/jeus/jeus6/config/HOST/keystore/keystore</keystore-file>
          <truststore-file>/home/jeus/jeus6/config/HOST/keystore/truststore</truststore-file>
          <keystore-type>JKS</keystore-type>
          <truststore-type>JKS</truststore-type>
          <keystore-pass>tmaxtest</keystore-pass>
          <keystore-keypassword>tmaxtest</keystore-keypassword>
          <truststore-pass>tmaxtest</truststore-pass>
        </ssl-config>
      </http-listener>
 
    </webserver-connection>
    <logging>
      <access-log>
        <handler>
          <file-handler>
            <name>handler1</name>
            <valid-day>1</valid-day>
          </file-handler>
        </handler>
      </access-log>
    </logging>
  </context-group>
</web-container>


반응형
반응형

아래 [예제]에서 이미지 파일을 선택하시며 미리보기가 됩니다.

 

핵심은 FileReader 객체인데 지원 가능한 브라우저는 아래와 같습니다.

 

Firefox (Gecko)

 Chrome

 Internet Explorer*

 Opera

 Safari

 3.6 (1.9.2)

 7

 10

 12.02

 6.0.2



[예제]

 

 

 

[코드]

 

 

반응형

'스크립트' 카테고리의 다른 글

css - 줄바꿈  (0) 2019.05.15
vim - 하이라이트 끄기  (0) 2019.05.13
IE img label for 클릭 안될때 처리  (4) 2019.03.27
User agent를 이용한 모바일 체크  (0) 2019.03.18
cmd process kill  (0) 2018.11.17
javascript padStart - left padding  (0) 2018.11.07
curl 기본 사용법  (0) 2018.11.07
jquery self unwrap  (0) 2018.11.06
반응형

사용법


scp a.txt 192.168.0.20:/home/goni
 
scp a.txt root@192.168.0.20:/home/goni
 
scp 192.168.0.10:a.txt 192.168.0.20:/home/goni
 
scp root@192.168.0.10:a.txt 192.168.0.20:/home/goni
 
scp -r /home/goni 192.168.0.20:/home/goni


-r 옵션은 sub directory 까지 복사

반응형

'리눅스' 카테고리의 다른 글

리눅스 비트 수 확인  (0) 2019.08.13
telnet 대신 방화벽 확인하기 - nc  (0) 2019.07.29
리눅스 프로세스 체크 후 시작하기  (0) 2019.07.19
리눅스 서버 시간대 (타임존) 변경  (0) 2019.04.07
tar 압축 해제  (0) 2018.10.12
리눅스 Jeus 6.0 설치  (0) 2018.09.30
ubuntu editor reset 우분투 편집기 초기화  (0) 2018.09.26
grep regex  (0) 2018.07.19
반응형

리눅스에서는 프로세스를 종료할 때는 kill 명령어를 쓰지만 윈도우에서는 taskkill 명령어를 이용합니다.

 

간단한 예제입니다.

 

80포트로 서비스하는 프로세스를 찾아서 죽이는 예제입니다.

 

 

1. 80 포트로 서비스하는 PID찾기.  "o" option 이 PID를 알려줍니다.

 

 

가장 오른쪽에 있는 숫자가 PID 입니다.

 

 

2. 해당 PID를 kill 합니다. "/pid" option 을 사용하면 pid 를 이용해 kill 할 수 있습니다.

 

 

3. "/f" option 을 사용하면 강제 종료할 수 있습니다.

 

 

반응형

'스크립트' 카테고리의 다른 글

vim - 하이라이트 끄기  (0) 2019.05.13
IE img label for 클릭 안될때 처리  (4) 2019.03.27
User agent를 이용한 모바일 체크  (0) 2019.03.18
html5 javascript 이미지 미리보기  (0) 2018.11.29
javascript padStart - left padding  (0) 2018.11.07
curl 기본 사용법  (0) 2018.11.07
jquery self unwrap  (0) 2018.11.06
jquery 확장 enter key function  (0) 2018.11.05
반응형

1. 확인

[root@goni9071 ~]# rpm -qa | grep MariaDB


2. 저장소 추가

[root@goni9071 ~]# vi /etc/yum.repos.d/MariaDB.repo


[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1


2-1. 저장소 확인

[root@goni9071 ~]# yum repolist


repo id                                   repo name                                                                        status
HP-mcp                                    HP Management Component Pack for ProLiant                                              5
HP-spp                                    HP Service Pack for ProLiant                                                       1,335
base                                      CentOS-6 - Base                                                                  6,704+9
epel                                      Extra Packages for Enterprise Linux 6 - x86_64                                    12,497
extras                                    CentOS-6 - Extras                                                                     33
mariadb                                   MariaDB                                                                               59
rpmforge                                  RHEL 6 - RPMforge.net - dag                                                      4,717+1
updates                                   CentOS-6 - Updates                                                                198+27
repolist: 25,548


3. 설치

[root@goni9071 ~]# yum install MariaDB-server


Dependencies Resolved
 
==================================================================================================================================
 Package                               Arch                   Version                               Repository               Size
==================================================================================================================================
Installing:
 MariaDB-server                        x86_64                 10.2.18-1.el6                         mariadb                 111 M
Installing for dependencies:
 MariaDB-client                        x86_64                 10.2.18-1.el6                         mariadb                  48 M
 MariaDB-common                        x86_64                 10.2.18-1.el6                         mariadb                 154 k
 MariaDB-compat                        x86_64                 10.2.18-1.el6                         mariadb                 4.0 M
 boost-program-options                 x86_64                 1.41.0-28.el6                         base                    108 k
 galera                                x86_64                 25.3.24-1.rhel6.el6                   mariadb                 8.8 M
 libaio                                x86_64                 0.3.107-10.el6                        base                     21 k
 perl-DBI                              x86_64                 1.609-4.el6                           base                    705 k
 
Transaction Summary
==================================================================================================================================
Install       8 Package(s)
 
Total download size: 173 M
Installed size: 730 M
Is this ok [y/N]:
 


Downloading Packages:
(1/8): MariaDB-10.2.18-centos6-x86_64-client.rpm                                                           |  48 MB     00:30
(2/8): MariaDB-10.2.18-centos6-x86_64-common.rpm                                                           | 154 kB     00:00
(3/8): MariaDB-10.2.18-centos6-x86_64-compat.rpm                                                           | 4.0 MB     00:01
(4/8): MariaDB-10.2.18-centos6-x86_64-server.rpm                                                           | 111 MB     00:36
(5/8): boost-program-options-1.41.0-28.el6.x86_64.rpm                                                      | 108 kB     00:00
(6/8): galera-25.3.24-1.rhel6.el6.x86_64.rpm                                                               | 8.8 MB     00:06
(7/8): libaio-0.3.107-10.el6.x86_64.rpm                                                                    |  21 kB     00:00
(8/8): perl-DBI-1.609-4.el6.x86_64.rpm                                                                     | 705 kB     00:00
----------------------------------------------------------------------------------------------------------------------------------
Total                                                                                             2.2 MB/s | 173 MB     01:17
warning: rpmts_HdrFromFdno: Header V4 DSA/SHA1 Signature, key ID 1bb943db: NOKEY
Retrieving key from https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
Importing GPG key 0x1BB943DB:
 Userid: "MariaDB Package Signing Key <package-signing-key@mariadb.org>"
 From  : https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
Is this ok [y/N]:
 



Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
** Found 2 pre-existing rpmdb problem(s), 'yum check' output follows:
kernel-firmware-2.6.32-754.3.5.el6.noarch is a duplicate with kernel-firmware-2.6.32-642.15.1.el6.noarch
kernel-headers-2.6.32-754.3.5.el6.x86_64 is a duplicate with kernel-headers-2.6.32-642.15.1.el6.x86_64
  Installing : MariaDB-compat-10.2.18-1.el6.x86_64                                                                                                                                                                                       1/8
  Installing : MariaDB-common-10.2.18-1.el6.x86_64                                                                                                                                                                                       2/8
warning: /etc/my.cnf created as /etc/my.cnf.rpmnew
  Installing : libaio-0.3.107-10.el6.x86_64                                                                                                                                                                                              3/8
  Installing : MariaDB-client-10.2.18-1.el6.x86_64                                                                                                                                                                                       4/8
  Installing : boost-program-options-1.41.0-28.el6.x86_64                                                                                                                                                                                5/8
  Installing : galera-25.3.24-1.rhel6.el6.x86_64                                                                                                                                                                                         6/8
  Installing : perl-DBI-1.609-4.el6.x86_64                                                                                                                                                                                               7/8
  Installing : MariaDB-server-10.2.18-1.el6.x86_64                                                                                                                                                                                       8/8
chown: cannot access `/var/lib/mysql': No such file or directory
 
 
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:
 
'/usr/bin/mysqladmin' -u root password 'new-password'
'/usr/bin/mysqladmin' -u root -h  password 'new-password'
 
Alternatively you can run:
'/usr/bin/mysql_secure_installation'
 
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
 
See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.
 
Please report any problems at http://mariadb.org/jira
 
The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/
 
  Verifying  : perl-DBI-1.609-4.el6.x86_64                                                                                                                                                                                               1/8
  Verifying  : MariaDB-server-10.2.18-1.el6.x86_64                                                                                                                                                                                       2/8
  Verifying  : MariaDB-common-10.2.18-1.el6.x86_64                                                                                                                                                                                       3/8
  Verifying  : galera-25.3.24-1.rhel6.el6.x86_64                                                                                                                                                                                         4/8
  Verifying  : MariaDB-compat-10.2.18-1.el6.x86_64                                                                                                                                                                                       5/8
  Verifying  : MariaDB-client-10.2.18-1.el6.x86_64                                                                                                                                                                                       6/8
  Verifying  : libaio-0.3.107-10.el6.x86_64                                                                                                                                                                                              7/8
  Verifying  : boost-program-options-1.41.0-28.el6.x86_64                                                                                                                                                                                8/8
 
Installed:
  MariaDB-server.x86_64 0:10.2.18-1.el6
 
Dependency Installed:
  MariaDB-client.x86_64 0:10.2.18-1.el6  MariaDB-common.x86_64 0:10.2.18-1.el6  MariaDB-compat.x86_64 0:10.2.18-1.el6  boost-program-options.x86_64 0:1.41.0-28.el6  galera.x86_64 0:25.3.24-1.rhel6.el6  libaio.x86_64 0:0.3.107-10.el6
  perl-DBI.x86_64 0:1.609-4.el6
 
Complete!
 


4. 확인

[root@goni9071 ~]# rpm -qa | grep MariaDB


MariaDB-client-10.2.18-1.el6.x86_64
MariaDB-server-10.2.18-1.el6.x86_64
MariaDB-compat-10.2.18-1.el6.x86_64
MariaDB-common-10.2.18-1.el6.x86_64


5. 시작

[root@goni9071 ~]# service mysql start
 
Starting MariaDB.181113 17:49:06 mysqld_safe Logging to '/var/lib/mysql/goni9071.tistory.com.err'.
181113 17:49:06 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
 SUCCESS!
 


6. 확인

[root@goni9071 ~]# netstat -an|grep 3306
tcp        0      0 :::3306                     :::*                        LISTE


7. root 패스워드 설정

[root@goni9071 ~]# mysqladmin -u root password


8. 접속

[root@goni9071 ~]# /usr/bin/mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 11
Server version: 10.2.18-MariaDB-log MariaDB Server
 
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
MariaDB [(none)]>



반응형
반응형

Mybatis 에서 <sql>, <include> 간단한 사용법입니다.


* <sql> 안에서 <prorperty> 로 받은 값을 <if>나 <bind> 에 쓰고 싶었는데 변수로 인식하지 못하는게 아쉬웠습니다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<sql id="columns">
    ${alias}id,
    ${alias}name,
    ${alias}age
</sql>
 
<insert id="insertUser">
    INSERT INTO USER (
           <include refid="columns"><property name="alias" value=""/></include>
         ) VALUES (
           #{entity.id},
           #{entity.name},
           #{entity.age})
</insert>
 
<select id="selectUser">
    SELECT <include refid="columns"><property name="alias" value="user."/></include>
      FROM USER user
     WHERE age = 15
</select>


반응형
반응형

자바스크립에서 특정 문자열 왼쪽에 문자열을 채우고 싶을 padStart 함수를 이용하면 됩니다.

하지만 지원하지 않는 브라우저나 버전이 있으므로 아래와 같이 정의해 놓고 사용하면 편합니다.

 

참고로, 아래코드는 왼쪽에 채울 문자열을 1자리만 허용하고 있습니다.

 

[Code]

 

 

[Test]

 
 

[Result]

 

반응형

'스크립트' 카테고리의 다른 글

IE img label for 클릭 안될때 처리  (4) 2019.03.27
User agent를 이용한 모바일 체크  (0) 2019.03.18
html5 javascript 이미지 미리보기  (0) 2018.11.29
cmd process kill  (0) 2018.11.17
curl 기본 사용법  (0) 2018.11.07
jquery self unwrap  (0) 2018.11.06
jquery 확장 enter key function  (0) 2018.11.05
javascript cookie getCookie setCookie  (0) 2018.11.05
반응형

[Option]

 

[Example]

 

 
반응형

'스크립트' 카테고리의 다른 글

User agent를 이용한 모바일 체크  (0) 2019.03.18
html5 javascript 이미지 미리보기  (0) 2018.11.29
cmd process kill  (0) 2018.11.17
javascript padStart - left padding  (0) 2018.11.07
jquery self unwrap  (0) 2018.11.06
jquery 확장 enter key function  (0) 2018.11.05
javascript cookie getCookie setCookie  (0) 2018.11.05
netstat unique ip  (0) 2018.09.10
반응형

간단한 랜덤 함수입니다.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  public static String getRandomAlphaNumeric(int len) {
    char[] charSet = { '0''1''2''3''4''5''6''7''8''9'
                       'a''b''c''d''e''f''g''h''i''j'
                       'k''l''m''n''o''p''q''r''s''t'
                       'u''v''w''x''y''z' };
 
    int idx = 0;
    StringBuffer sb = new StringBuffer();
 
    for (int i = 0; i < len; i++) {
      idx = (int) (charSet.length * Math.random());
      sb.append(charSet[idx]);
    }
 
    return sb.toString();
  }


반응형

+ Recent posts