spring-projects-experimental / spring-fu

Configuration DSLs for Spring Boot
Apache License 2.0
1.67k stars 139 forks source link

enable function is protected #372

Open lwenxu opened 3 years ago

lwenxu commented 3 years ago

when i use it in springboot proj , and use sample case:

   public static JafuApplication app = webApplication(a -> a.beans(b -> b
            .enable(webMvc(s -> s
                    .port(s.profiles().contains("test") ? 8181 : 8080)
                    .router(router -> {

                    }).converters(c -> c
                            .string()
                            .jackson()))));

i get that result , i can't compile that , and i want to call s.initialize() but i can't get bean context any more

image

lwenxu commented 3 years ago

after reading the code , i modified code to this and it works

    public static JafuApplication app = Jafu.webApplication(ioc ->
            ioc
                    .beans(beanDefinition ->
                            beanDefinition.bean(SampleHandler.class)
                                    .bean(SampleService.class)
                                    .bean(Sample.class))
                    .logging(loggingDsl -> loggingDsl.level(LogLevel.DEBUG))
                    .enable(WebMvcServerDsl.webMvc(dsl ->
                            dsl.port(dsl.profiles().contains("test") ? 8181 : 8080)
                                    .router(router -> {
                                        SampleHandler handler = dsl.ref(SampleHandler.class);
                                        router.GET("/sayHello", handler::hello);
                                    })
                                    .converters(c ->
                                            c.string().jackson()
                                    )
                    ))
    );

I strongly recommend that  change the demo code on readme to this