私は春のブートレストサービスを開始しています。これは、特定のRESTコントローラがある場合には、ディストリビューションにいくつかのjarファイルが含まれることがあることを意味します。restコントローラのインポート/ロードをプログラムで強制的に行う方法
どのように私はspring-bootに設定ファイルがあるコントローラをどこに見つけるかを伝えることができます。今私は注釈でこの情報を送って、1つの配布ごとに「メイン」を作成するようにしています。ファイルに定義されているコントローラをインポートするユニークなメインを定義したいと思います。言い換えれば、私は怒鳴るsnipedに示されているように手動@Import
注釈にアクセスしたい:私はcorretlyあなたを理解していれば
@Configuration
@PropertySource("conf.cfg")
@Import(value = {RestContorller1.class, RestContorller2.class})
@EnableAutoConfiguration
@ConfigurationProperties
@SpringBootApplication
@RestController
@EnableSwagger2
public class Application {
public static void main(String[] args) {
String confFile = Const.DEFAULT_CONFIGURATION_FILE;
if(args.length>0)
confFile= args[0];
System.setProperty("spring.config.name",confFile);
Boolean hasStarted = DataProcessingCore.start(confFile);
if(hasStarted) {
SpringApplication springApp = new SpringApplication(Application.class);
try {
springApp.setDefaultProperties(Utils.createPropertyFiles(confFile));
} catch (IOException e) {
e.printStackTrace();
}
springApp.addInitializers();
springApp.run(args);
}
}
}