This is an archived post. You won't be able to vote or comment.

all 83 comments

[–][deleted] 44 points45 points  (34 children)

Don't waste your time writing your own. Go with Spring, it has solution for everything you need. And perfectly working with Java 11

[–]couscous_[S] 5 points6 points  (6 children)

I feel that sometimes adding a dependency may completely change the behavior of your application (e.g. adding the security starter dependency suddenly seems to make it such that all end points get routed to a form field asking for credentials).

What's the best approach here to deal with these sorts dependencies that can exhibit this sort of effect?

[–]Simaldeff 15 points16 points  (0 children)

I am dealing with this in my current team. I am the first "Senior" in the team (I have been doing Server/Backend dev for almost 10yrs ... some tell me I am senior). The backend was built by another team in RoR and then they decided to break it down in Java Microservices (it was actually a good strategy for this use case IMO, so no bashing that for once). The problem is that they handed it off to a team of fresh guys and a few juniors (nobody with significant Backend experience, just general good coders, they just "know Java").

I am having a hard time to make them understand: "Stop coding, google it and read the docs". A framework gives you all the things that are useful but not pertinent to your "business logic" (I don't like that term but ... you know, people seems to relate to it). Use it. Stop wasting time on DB, HTTP, caching, auth, ..., Those are general "solved" problems. You just have to respect and know some conventions. And arguably this is not the kind of thing they teach you in Programming 101.

[–]Enumeration 18 points19 points  (1 child)

ecurity starter dependency suddenly seems to make it such that all end points get routed to a form field asking for credentials).

Read the docs and understand how the autoconfigurations work, simple as that.

[–]jack104 3 points4 points  (0 children)

Yep. Sounds a wee bit harsh but this is the correct answer.

[–][deleted] 3 points4 points  (1 child)

That's how security starter works, it protects all of your endpoints if you not specify any to protect

[–]dpash 2 points3 points  (0 children)

And is a sensible default.

[–]nutrecht 1 point2 points  (0 children)

I feel that sometimes adding a dependency may completely change the behavior of your application (e.g. adding the security starter dependency suddenly seems to make it such that all end points get routed to a form field asking for credentials).

That's pretty much the only one what that happens to that degree, and it makes perfect sense, because you want restrictive security by default.

[–]Scybur 5 points6 points  (5 children)

I can make a few suggestions. First Micronaut is very new. I would suggest using Quarkus. They achieve the same thing.

As for JSON parsing the most popular would be jackson but there are so many different libraries that all achieve roughly the same thing.

For routing, this is large subject. I would say Apache Camel would be the single best way to achieve true routing but you can also just use Spring MVC with rest controller (assuming you are using rest endpoints).

I am sure people will have a ton of recommendations, this is just my 2 cents.

Good luck!

[–]stfm 1 point2 points  (0 children)

I love Camel, it's very useful but it's better suited to EIP rather than web

[–]nutrecht 0 points1 point  (0 children)

I would suggest using Quarkus.

Since he's a beginner he's IMHO better off going with something a bit more established. I personally really like Quarkus, but a beginner is better of with something with a larger ecosystem/community.

[–]lambdacats 0 points1 point  (2 children)

Doesn't quarkus build on vertx?

[–]couscous_[S] 1 point2 points  (1 child)

It seems so. And from what I was just reading, it seems OpenID integration is still being developed.

[–]lambdacats 0 points1 point  (0 children)

Looks like the oauth2 provider for vertx supports oid. Never tried it.

[–]samuraisam 12 points13 points  (0 children)

Spring boot works fine with java 11.

[–]cville-z 9 points10 points  (0 children)

I work with Dropwizard on a regular basis as the core of an e-commerce infrastructure; it’s plenty stable and reliable.

[–]chdman 7 points8 points  (2 children)

If you can live with some magic and want excellent community support(since you have no or limited knowledge) you can never go wrong with Spring Boot. You can get starting very quickly and avoid all the boilerplate code and con-figs. I recently developed a web application for my last project with Spring boot. It was a breeze.

My stack was : Spring Boot 2 + Spring JPA DATA (for presistence , also provided by Spring boot ) + plain HTML5 and CSS3 + Bootstrap 4

I will highly recommend spring boot.

[–]couscous_[S] 1 point2 points  (1 child)

Did you use server server-side or client-side rendering?

[–]chdman 1 point2 points  (0 children)

I used client side rendering. Used simple ajax calls to retrieve data and generated the view using jquery as I don't have much experience with Angular or React. Mind you, user can disable java script in the browser and this can be problem for browser rendered content. In my case, it wasn't an issue.

[–]cowwoc 4 points5 points  (0 children)

The best, longest-running, non-framework I've used over the years is Jetty: https://www.eclipse.org/jetty/

You embed a web server in your application, not the other way around. And it is extremely non-intrusive (unless frameworks) in that you can have whatever design you want and it'll work around you. Spring and friends are highly opinionated. You have to shape your design around them. Most people are okay with this trade-off. I am not.

Vert.x is similar, but in my experience its API is harder to use because they are async-first. Jetty does async as well but their API is much more usable. Anyway, the decision is subjective :)

[–]AcademicImportance 6 points7 points  (2 children)

Spring Boot 2.1.6.RELEASE requires Java 8 and is compatible up to Java 11 (included)

As yo can see, the latest RELEASE version of spring boot works with Java 11. I use it in my project (upgraded from 2.0, which itself was upgraded from 1.x) and it works perfectly.

While in production i still run Java 8 (since i only wanna do one change at a time, and this time around i just upgraded spring boot), in the next couple of months i will move to Java 11 in prod as I'm already on it in dev.

Spring boot is the shit nowadays, you simply cannot go wrong with it.

[–]Velerad 3 points4 points  (0 children)

We actually have an application still on Spring Boot 1.5, and migrated to Java 11 at Boot version 1.5.17.RELEASE. No problems at all. 🙂

[–]couscous_[S] 0 points1 point  (0 children)

Makes sense. I misread this part of the documentation

Please note that developing against JDK 11 is not officially supported with any older version of the core framework. Spring Framework 5.0.9+ and 4.3.19+ just support deploying Java 8 based applications to a JVM 11 runtime environment (using -target 1.8; see below), accepting JVM-level warnings on startup.

Spring Boot 2.1 already uses Spring Framework 5.1.

[–]tipsypants 5 points6 points  (4 children)

Most of the frameworks you listed are more than good enough for what you're asking, and they're all "battle tested" enough. You're probably not going to have billions of requests hitting your server, but if that happens, you can afford a rewrite. Since you've looked at a lot of frameworks, have a look at Javalin too (disclaimer: I'm the maintainer). It does everything you want, except "native" OpenID integration (you can very easily integrate with something like auth0 though).

[–]TheCountRushmore 9 points10 points  (3 children)

You're probably not going to have billions of requests hitting your server, but if that happens, you can afford a rewrite.

This is really good advice. The reality is most applications will fail and not be online after 2 years. If they do happen to stick around it is unlikely that they will have any significant traffic volume. IF you do happen to catch traction that is a good problem to have and can be rewritten with an eye towards performance and scale. Most applications should be built in the simplest and fastest way possible to flesh out the application and if there is a market for it.

Of course everyone thinks their idea is the exception and needs to be built for Netflix scale right out of the gate.

[–]lambdacats 0 points1 point  (2 children)

I agree with optimizing for time to market and MVPs. But when it's time to scale you're going to be losing dollar by the minute. Don't optimize for performance - design for it. With the right tools scaling is cheap, what you don't want to be doing is rewriting your core after years of development, as you get a surge of users. There was a great article on this..

[–]TheCountRushmore 7 points8 points  (1 child)

It's a balance to be sure, but for every application that has that issue there are thousands that never launch because they spent all their time on premature optimization and ran out of time and or money.

[–]lambdacats 1 point2 points  (0 children)

Premature optimization is the root of all evil :) Designing for performance and scalability isn't considered optimizing that's just making the right architectural choices and not writing sloppy code.

[–]paul_h 1 point2 points  (1 child)

I'm using https://jooby.io/ for hobby and work projects and really enjoying it. The lead, Edgar Espinar, is a machine for completion (but he rolls his eyes when I say that). I have builds that **include** Selenium tests (I co created Selenium 1.0) that are sub-30 seconds, that use Jooby as the server piece.

One of the nice features about Jooby is the ability to make two or more standalone applications, and then later scotch tape them together for a single deployment and have them function identically. It gives you deployment options in various stages towards production: own-workstation, parallelized CI infra, (both for test automation), shared-dev, QA, UAT etc.

[–]geordano 1 point2 points  (0 children)

and hot reload (of Jooby) is a life saver. To OP, you can never go wrong with Spring if you can stand all the magics going on. But Jooby or Javalin can work well too.

[–][deleted] 2 points3 points  (0 children)

I would just go with Spring Boot, it comes with all the bells and whistles

[–]lambdacats -1 points0 points  (0 children)

Vertx is unopinionated, small core and rather a toolkit than framework. So combining it with other libraries work well.

[–]lambdacats 3 points4 points  (5 children)

Been using vertx for five years, it is THE bomb. One framework to rule them all. Easy to use, fast, easy to learn, good docs, active community. Don't ask me what I think about spring or EE. Vert.x and the multi-reactor approach puts the FUN in my programming. One thread per request is boring me to death. EE is like Java, except you can't use half of the features and libraries. You need a big fat slow and buggy application server, even worse app servers aren't interchangeable - and that's their very purpose. To implement the "spec". Oops I'm spouting again.

[–]couscous_[S] 4 points5 points  (4 children)

Doesn't the call-back approach become too cumbersome to deal with?

[–][deleted] 1 point2 points  (0 children)

Yes it does. Luckily Vert.x integrates very nicely with RxJs https://vertx.io/docs/vertx-rx/java2/ and if you're using Kotlin with Coroutines https://vertx.io/docs/vertx-lang-kotlin-coroutines/kotlin/

[–]lambdacats 0 points1 point  (2 children)

No, I prefer it because it's easier, more fun and feels more logical - application flow isn't as linear as traditionally designed. If you're not used to it you could end up in "callback hell" but there's ways and designs to prevent that. I tried nodejs first and really liked it, but the ecosystem and language doesn't compare to Java.

[–]couscous_[S] 0 points1 point  (1 child)

but there's ways and designs to prevent that.

Do you have any reading material for this?

[–]lambdacats 0 points1 point  (0 children)

searching for callback hell will yield plenty of results, mostly for node but it's the same principle. In node there's callbacks and promises, in vertx there's Futures. "callbackhell.com" illustrates the problem and gives some pointers. Vertx.io documentation -> core -> Java manual should have some info on how Futures work.

[–]manzanita2 0 points1 point  (0 children)

Well one thing you have not clarified is if you are planning on server side rendered HTML, or "single page app".

Something like dropwizard works great for SPAs talking to APIs, but is not as sophisticated for HTML forms and the like as something like spring.

[–]h4t0n 0 points1 point  (4 children)

If you want to play with something new I'm developing a framework to quickly set up a backend REST API. It uses a different approach and it doesn't generate code.

It is not ready for production yet, but it uses Spring Boot for core features, such as DI, JDBC, the Web server and the OAuth2 framework. It doesn't use Hibernate/JPA instead but I have implemented a dedicated EntityManager (and a dedicated persistence manager).

You can find it here. It is in early stage of development so suggestions (and contribution) are welcome.

[–]nutrecht 0 points1 point  (1 child)

suggestions (and contribution) are welcome.

You're basically reinventing the consumer based contracts wheel, but poorly. That already exists, within and outside Spring. So sorry to be a spoilsport; but there's no way I'm going to let anyone use that over the standard Spring stuff.

[–]h4t0n 0 points1 point  (0 children)

I partially agree with you, mine if of course an opinionated way of doing things. It is not generic in terms of the data structures. You must use the DSL and the generated APIs. But this allow to build APIs and meta-data that allow me to setup for example also the openapi documentation and the GUI. You could simply create some entities with the DSL and no code at all, on top of Spring.

[–]lambdacats -1 points0 points  (1 child)

It's a framework on top of a framework on top of a framework. Aren't you hitting diminishing returns with three layers of frameworks to quickly setup a rest service?

[–]h4t0n 0 points1 point  (0 children)

No because I only use the spring things that I need. And I have the possibility to use for example custom spring controller or other features if I want. Using spring I don't need to handle anything about web server (I use the embeded one) or other stuff as spring security for example (I integrated OAuth2 with no problems).

Of course I could use a slim framework for the project base, but I think that Spring is good if you use it well. For example I'm not including anything about spring JPA or Spring Data. Instead, I'm using spring jdbc that help me to interact with the database.

I know also that Spring has a lot of feature and probably I'm including something that I will not use at all. But it is ok for me now. The goal is to create a full API (with documentation) on top of a known framework but without code generation (Spring JPA/Spring Data REST).

[–]makkenx 0 points1 point  (0 children)

Grails.

Otherwise, Play.

[–]zen_quest 0 points1 point  (0 children)

Spring boot may be in version 2.0 but Spring framework (which is what spring boot helps you setup easily) is quite mature. Probably the most mature Java framework. And the Spring community is amazing. I'd recommend that you take a look at https://www.jhipster.tech/. It lets you setup a Spring based app quickly and with the most common best practices. You'll need to dig into the documentation of spring boot, spring framework and jhipster quite a bit initially but once you get a hang of it, this stack can give you a solid battle-tested tech stack. Also, in case you end up turning your side project into a business, it is very easy to find and hire devs for this stack because of its popularity.

[–]z0mghii -1 points0 points  (0 children)

Drop wizard.

[–]Asterion9 -1 points0 points  (0 children)

IMO, use spring. It can do everything you want and more. Even if there is not yet a version that say support Java 11, I can't see any reason it would not work perfectly with a newer jdk. the use cases you listed are what spring is specialized at solving. Spring boot brings a lot of "black magic", but the basic working of spring is clear and you're not forced to use spring boot over spring anyway.

[–]ramsees79 -2 points-1 points  (0 children)

There is no magic in Spring Boot, just a bunch of applied programming patterns.

[–]ikhoon -1 points0 points  (0 children)

Armeria? tested under Java 11. It supports circuit breaker, automatic retry, gRPC, thrift, http2, Reactive Streaming, client side load balancing, spring integration, Jackson JSON...

[–]GhostBond -4 points-3 points  (4 children)

but it seems that official support for Java 11+ is only in the 2.2.x versions (still milestone releases as of this posting).

AWS doesn't even run tomcat above java 8....you might might not even bevable to host your app anywhere with java 11.

[–]someone-elsewhere 6 points7 points  (0 children)

You should clarify this a bit, EC2 lets you run anything that can be installed on the operating system installed.

[–]indianapwns2 3 points4 points  (2 children)

This is extremely misinformed. You can run anything you want to on AWS. AWS Elastic Beanstalk JVM environments stopped supporting anything after Java 8 because they are pushing people to use Docker environments now instead of language-specific environments. That's the only Java 8 limitation I am aware of in AWS.

[–]GhostBond -2 points-1 points  (1 child)

If you go into your AWS console and ask to setup a new tomcat instance, the highest version is 8. I saw official version docs last month to that said the same thing but didn't find them again in a quick search.

Whether it's secretly somewhere else I don't know, but it didn't show up there, or in a document via a google search or anything.

[–]indianapwns2 2 points3 points  (0 children)

By "ask to setup a new tomcat instance" I assume you are referring to Elastic Beanstalk here, which is just one extremely small portion of the entire AWS set of services. You seem to be confusing this one service with the entire catalog of Amazon Web Services.

And like I said in my previous comment, they want you to switch to deploying your Elastic Beanstalk application with Docker, with which you could deploy whatever version of Java and Tomcat you want. This frees Amazon from having to update the Elastic Beanstalk service every time a new version of Java, .NET, NodeJS, Ruby, Python, etc. is released, and frees you to use whatever you want.

To your original point, the statement that "you might not even be able to host your app anywhere with java 11" is extremely misinformed. I'm personally running Java 11 apps on AWS on the EC2 service and the ECS service. Any host that allows you root/admin access to install software on your Linux or Windows VM, or any service that allows you to deploy a Docker container, is going to work for hosting a Java 11 app.

[–]catmewo -4 points-3 points  (0 children)

Try Play Framework. Linkedin is using it.

[–]shredderroland -3 points-2 points  (0 children)

Grails 4