4 ms·
I have to agree on everything that author has stated. I also hate Spring with all my heart. I have hated it 10 years ago, now got onto a project that is using S
by szastamasta 5y ago
I have to agree on everything that author has stated. I also hate Spring with all my heart. I have hated it 10 years ago, now got onto a project that is using Spring Boot and hate it again.
It has nothing to do with XML, it's that Spring is full of interdependent, classpath and annotation driven magic that no one knows how will wire things up before runtime.
A lot of stuff is just a plain string in annotation value that you cannot find or refactor, because it's not code.
Worst of all, there's usually no gain from using it. You usually trade 1 line for 1 line - instead of using compile time checked method calls, you type a cryptic annotation that is validated at runtime.
There's a lot of really bad solutions to problems there, like Spring Data Rest or auto generated repositories that force you to have setters for all fields in your models. Or stuff that simply does not work: https://stackoverflow.com/questions/34210903/springdatarest-repositoryeventhandler-not-running-when-controller-is-added https://stackoverflow.com/questions/34210903/springdatarest-...
Sometimes, after few hours of fighting it's way of doing things I just re-write what it supposed to do in few lines of Java code. And it's usually faster to write and easier to understand.
Sorry, I just cannot find any love for it. I really hate it when I have to write another AbstractAnnotationConfigDispatcherServletInitializer...
- deepGem 5y agoJava annotations are terrible to reason about. Once you get a hang of them, then it's somewhat easier. That being said, Spring takes these annotations to the next level of complexity. Spring boot just makes this more difficult to reason about with added annotations. Anyone who states that Spring annotations are just 'abstractions' and that's how software is built is welcome for a healthy argument. There are much better web development alternatives such as Javalin. Compare this import io.javalin.Javalin; public class HelloWorld { public static void main(String[] args) { Javalin app = Javalin.create().start(7070); app.get("/", ctx -> ctx.result("Hello World")); } } to @SpringBootApplication @RestController public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } @GetMapping("/hello") public String hello(@RequestParam(value = "name", defaultValue = "World") String name) { return String.format("Hello %s!", name); } } However, Spring cloud, has all the necessary distributed features built in. While I haven't used these, not having to write code for these is a god send. Load balancer - Check Service mesh - Check Circuit breaker - Check Heck, they have even included all Netflix OSS components. So this alone is worth the pain of living with annotations. https://spring.io/projects/spring-cloud https://spring.io/projects/spring-cloud
- kaba0 5y agoI doubt that a hello world could meaningfully compare the two. What about a complex web app with many more http endpoints? Some of them having parameters that should be queried from, validated and converted from the URL? It is still the same amount of lines in Spring. Declerative does win in my opinion in this case.
- deepGem 5y agoThe pain point raised was about annotations. So just providing an example framework that doesn't use annotations or any other code magic.
- tubs 5y agoYour javalin example returns a static string and doesn't read parameters so how is it a meaningful comparison?