Created
January 26, 2021 08:17
-
-
Save suzukitadashi/c2d0f3c8ce75783cb449436da2d473eb to your computer and use it in GitHub Desktop.
こんなことできる?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
public static void main(String[] args) { | |
Bean bean = BeanFactory.create("aBean"); | |
bean.run(); | |
} | |
} | |
@Component("aBean") | |
public class ABean { | |
public void run() { | |
System.out.println("aBeanが呼ばれた"); | |
} | |
} | |
@Component("bBean") | |
public class BBean { | |
public void run() { | |
System.out.println("bBeanが呼ばれた"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ブログで書いてらっしゃった目的なら、
CommandLineRunner
で処理を書いてProfileで実行するものを切り替える方法もあります。プロファイルについてはこちら→Springのプロファイル機能、そしてSpring Bootのapplication.properties
@Order
で実行順序を指定できます(整数値の昇順)。