1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | RatpackServer.start(server -> server .registry(spring(AppConfiguration.class)) .handlers(chain -> chain .get(ctx -> ctx .render(ctx.get(Greeting.class).say("Alex"))) ) ); public interface Greeting { String say(final String name); } @Configuration class AppConfiguration { @Bean public Greeting greeting() { return name -> String.format("Hello, %s", name); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | @SpringBootApplication @EnableRatpack public class SpringBootApp { @Bean public Action<Chain> index() { return chain -> chain .get(ctx -> ctx .render(greeting().say("Alex")) ); } public Greeting greeting() { return name -> String.format("Hello, %s", name); } public static void main(String... args) throws Exception { SpringApplication.run(SpringBootApp.class, args); } } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |