4 ms·
Dropwizard is great for REST APIs (... as the title says). However if you want to use traditional views (MVC, html templates, security, forms etc) then please c
by spapas82 10y ago
Dropwizard is great for REST APIs (... as the title says). However if you want to use traditional views (MVC, html templates, security, forms etc) then please check something else (I tried it and lost many hours -- in the end I still couldn't do even basic things).
For traditional web development, I recommend spring-boot which is almost as easy as dropwizard, it also doesn't need an application container and fully supports Spring MVC, Spring Security and all other spring related goodies.
- jsight 10y agoWhat templating language did you use with Spring MVC?
- spapas82 10y agothymeleaf (http://www.thymeleaf.org/ http://www.thymeleaf.org/) - it is supported directly by spring boot (spring-boot-starter-thymeleaf dependecy). Also, using thymeleaf-extras-springsecurity4 you can integrate spring security tags with thymeleaf so that you can conditionally render things depending on the current user/authority into your templates!
- Deinumite 10y agoI've been looking at http://www.mitchellbosecke.com/pebble/home http://www.mitchellbosecke.com/pebble/home but I have not yet had a chance to use it.
- spapas82 10y agoHmmm seems nice and has a djangonic syntax! However I'm not really sure how easy would be to integrate with spring boot (and spring security)...
- Deinumite 10y agoI'm not sure about Spring Security but as for Spring Boot itself http://www.mitchellbosecke.com/pebble/documentation/guide/spring-integration http://www.mitchellbosecke.com/pebble/documentation/guide/sp...
- manyxcxi 10y agoI've been using Thymeleaf with Spring for a while and almost always exclusively use it with Spring Boot because it's pretty much right out of the box ready to go. I stumbled on it a long time ago because I had the problem of Java devs needing to integrate templates built by front end devs and all the churn that goes along with it. It uses custom tag attributes like th:href to swap the computed value in on template render so you can have a completely perfect looking HTML/CSS/JS template with the placeholder values without having to convert back and forth. It's just HTML with extra attributes that get ignored when not run through the rendering process. You can use Spring Expressions, forms, and security with pretty much no configuration, it works awesome. It supports partials and layouts and all the good stuff you'd want for reuse and it took me about 10 minutes to create a custom dialect for it that lets me use Thymeleaf and Vue.js together very nicely. I can't recommend Thymeleaf enough.
- kentosi 10y agoOne issue is if you're using Angular. Your html document needs to be xhtml compatible, meaning that an expression like this: <div ng-if="this() && that()" ... Needs to become: <div ng-if="this() && that()" ... If this doesn't bother you (along with > for <, etc) then go ahead.
- manyxcxi 10y agoIt doesn't have to if you write your own dialect for Thymeleaf. You can alter the flow of the output manipulation and validation- it's out of the box that it chokes on the 'weird' stuff being shoved into attribute tags nowadays for JS templates. If you want the unescaped output there are lots of things you can do. I did something similar for Vue.js in about twenty minutes and a few lines of code.
- tootie 10y agoFreemarker. Why doesn't every template language have macros?
- crypto5 10y agoDropwizard has templating engines integration and form validation.
- spapas82 10y agoI'm aware of that. However, have you tried using them in any non-trivial project? (for example, a project that supports authentication ?)
- gresrun 10y agoI successfully deployed several internal apps using DropWizard (0.9.x) with two different authentication schemes last year. Wasn't too difficult.
- StreamBright 10y agoWe are actively using it for things like that. What is your actual problem, could you show some code?
- spapas82 10y agoThere's some time since I stopped trying to work with dropwizard on non-REST projects so I've forgotten most of my problems. Some of those that I wasn't able to resolve are: - Integrating with spring-security - Integrating spring-security-tags (sec:authorize etc) in the templates - Using a different template engine in general (wanted to use thymeleaf) - Not able to bind forms to objects - Enabling pagination Please notice that all these are related to my specific needs (server side views) and, when trying dropwizard I had all these already solved with spring-mvc. Maybe if I kept pushing I'd be able to resolve most of these but, because of lack of documentation, and generaly because I understood that dropwizard should be used to create REST APIs, not server-side views I just switched to spring boot.
- tokenizerrr 10y agoI agree completely. For a long time I was avoiding Spring because bloat and XML, but then I finally gave in and tried Spring Boot. It is most excellent. Nearly all bloat is opt-in, it does everything, and absolutely zero XML configuration needed. I've tried Dropwizard before, and use it for two applications I have running. It works, but it's not great (because it's not just a rest API, but also has GUI and user management). I'll be porting it to Spring eventually.
- einrealist 10y agoWe do our "MVC" stuff with Dropwizard. There are some minor quirks (like validation). But we find it suitable enough for how we build our applications. The upcoming javax.mvc standard will probably find its way into Jersey and Dropwizard. For the views, we use Freemarker (Thymeleaf was too slow and less extensible).
- tootie 10y agoDropwizard is basically a subset of Spring. Spring can do a REST API just as easily, but also does everything else. I've used both, Dropwizard is great but there's no use case I'd select it over Spring.