Skip to content

Commit

Permalink
enable-module模块:添加启动类
Browse files Browse the repository at this point in the history
  • Loading branch information
guolanren committed May 19, 2020
1 parent c4bb678 commit 6b3915d
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package name.guolanren;

import name.guolanren.annotation.EnableByImportConfiguration;
import name.guolanren.annotation.EnableByImportImportBeanDefinitionRegistrar;
import name.guolanren.annotation.EnableByImportImportSelector;
import name.guolanren.service.Server;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
* @author guolanren
*/
@SpringBootApplication
@EnableByImportConfiguration
//@EnableByImportImportSelector(type = Server.Type.HTTP)
//@EnableByImportImportBeanDefinitionRegistrar(type = Server.Type.HTTP)
public class EnableModuleApplication implements CommandLineRunner {

@Autowired
private Server server;

public static void main(String[] args) {
SpringApplication.run(EnableModuleApplication.class, args);
}

@Override
public void run(String... args) throws Exception {
server.start();
server.stop();
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package name.guolanren.config;

import name.guolanren.service.HttpServer;
import name.guolanren.service.Server;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
* @author guolanren
*/
@Configuration
public class SomeConfiguration {

@Bean
public String sth() {
return "Hello, World";
public Server httpServer() {
return new HttpServer();
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package name.guolanren.service;

import org.springframework.stereotype.Service;

/**
* @author guolanren
*/
@Service
public class FtpServer implements Server {
public void start() {
System.out.println("FTP 服务器启动中...");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package name.guolanren.service;

import org.springframework.stereotype.Service;

/**
* @author guolanren
*/
@Service
public class HttpServer implements Server {
public void start() {
System.out.println("HTTP 服务器启动中...");
Expand Down

0 comments on commit 6b3915d

Please sign in to comment.