'run'에 해당되는 글 2건

  1. 2021.09.27 [SpringBoot] Application 실행 시 특정 작업 실행 시키기
  2. 2020.06.01 [Spring] Spring boot jar build and run.

[SpringBoot] Application 실행 시 특정 작업 실행 시키기

ITWeb/개발일반 2021. 9. 27. 12:39

아래 세 가지 방법으로 실행 시킬 수 있습니다.

@Component
public class RunAfterApplicationStart implements ApplicationRunner {

    @Override
    public void run(ApplicationArguments args) {
        // 실행 코드
    }
}

@Component
public class RunAfterApplicationStart implements CommandLineRunner {

    @Override
    public void run(String... args) {
        // 실행 코드
    }
}

@Component
public class RunAfterApplicationStart {

    @EventListener(ApplicationReadyEvent.class)
    public void hello() {
        // 실행 코드
    }
}

 

:

[Spring] Spring boot jar build and run.

ITWeb/개발일반 2020. 6. 1. 18:05

build.gradle)
plugins {
  id 'org.springframework.boot' version '2.3.0.RELEASE'
...중략...
  id 'java'
  id 'war'
}

...중략...

task projectVersion {
  doLast {
    println "${project.version}"
  }
}

task jarName {
  doLast {
    println "${archivesBaseName}-${version}.jar"
  }
}

bootJar {
  archivesBaseName = "springboot-was"
}

war {
  enabled = true
  archivesBaseName = "springboot-was"
}

 

build)
$ ./gradlew clean build bootJar

 

run)
$ sudo java -Djava.security.egd=file:/dev/./urandom -jar springboot-was.jar

 

springboot 프로젝트로 빌드 후 embedded tomcat 으로 실행 하는 예제 입니다.

: