「Spring Boot」ApplicationArguments インターフェースを使うサンプル

書式

publci 関数名(ApplicationArguments args)

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
import org.springframework.boot.*;
import org.springframework.beans.factory.annotation.*;
import org.springframework.stereotype.*;
@Component
public class UserBean {
@Autowired
public UserBean(ApplicationArguments args) {
boolean flg = args.containsOption("debug");
List<String> cftLst = args.getNonOptionArgs();
// some code
}
}
import org.springframework.boot.*; import org.springframework.beans.factory.annotation.*; import org.springframework.stereotype.*; @Component public class UserBean { @Autowired public UserBean(ApplicationArguments args) { boolean flg = args.containsOption("debug"); List<String> cftLst = args.getNonOptionArgs(); // some code } }
import org.springframework.boot.*;
import org.springframework.beans.factory.annotation.*;
import org.springframework.stereotype.*;

@Component
public class UserBean {

    @Autowired
    public UserBean(ApplicationArguments args) {
        boolean flg = args.containsOption("debug");
        List<String> cftLst = args.getNonOptionArgs();
        // some code
    }

}

 

Spring Boot

Posted by arkgame