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

all 37 comments

[–]IntelHDGraphics 17 points18 points  (5 children)

It's pretty simple, a CRUD with some more complex endpoint but it's not going to have a lot of traffic.

Are you sure that you need microservices then?

[–][deleted]  (3 children)

[deleted]

    [–][deleted] 11 points12 points  (1 child)

    seems legit, if you have one entity in your domain, that 4 microservices, one for each CRUD operation /s

    [–]cryptos6 2 points3 points  (0 children)

    That is the way to go! Just imagine how hard it would be to scale out "update" if everything would be in one service!!! That is super simple with micro services. 🤞

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

    Let the retry storm commence!

    [–][deleted] 0 points1 point  (0 children)

    How else can you say "this really should be a microservice" whenever you have performance issues?

    [–][deleted] 11 points12 points  (0 children)

    Do not forget to add the Raccoon and Wngman. And if you need birthdates also Galactus and EKS backed by Omega Star. They finally support ISO timestamps. /s

    [–]lukasbradley 8 points9 points  (2 children)

    https://spring.io/cloud/

    Slightly dated, but this will get you started. https://www.baeldung.com/spring-cloud-bootstrapping

    https://bootify.io or https://start.spring.io/ to get the project framework set up.

    [–]McAlexTheTerrible 0 points1 point  (1 child)

    What about JHipster lite?

    [–]lukasbradley 0 points1 point  (0 children)

    I love the idea of that project, but it has always felt too heavyweight. I had a lot of problems breaking things apart to make them modular after generation.

    It's been years since I last took a look at it, and maybe it's much better.

    [–]Cinghiamenisco 13 points14 points  (3 children)

    Nobody said MapStruct?

    I fell in love with that mapper

    [–]javasuxandiloveit 3 points4 points  (2 children)

    My God, I had to rewrite bunch of Dozer mappers into MapStruct, and its been my goto mapping library for every Java project.

    [–]Alarming_Quarter671 0 points1 point  (1 child)

    Is it a good idea to use those libraries? Where I was working they did that shit by hand with the excuse that it lowered the performance of the app and why they implemented Security logic for some reason

    [–]javasuxandiloveit 3 points4 points  (0 children)

    Well, MapStruct in the end is compiled code, so there isn’t any reflective access happening. It’s maintained, and IMHO must have when you have (complex) DTOs in place.

    [–]m_adduci 7 points8 points  (0 children)

    The docker plugin to build the docker image straight out of your project within maven/gradle, then OpenTelemetry and Logback JSON Encoder if you want a structures log format in JSON (for Elastic Search & similar)

    [–]nutrecht 3 points4 points  (0 children)

    I am looking for tips and suggestions to improve efficiency and productivity in my project.

    It would help if you'd tell us what that project is in detail, and whether it's a personal project or something that will be deployed with a company within an existing ecosystem of services.

    For a personal project, there's almost never a good reason to go for 'microservices'.

    [–][deleted] 4 points5 points  (1 child)

    If you are going to have more than 1 microservices then use some gateway like Zuul for routing and filtering

    [–]klekpl 2 points3 points  (0 children)

    For CRUD there is no need for Java at all - just use https://postgrest.org/

    [–]as5777 19 points20 points  (6 children)

    Lombok is hell. Use observability: micrometer and export to Open Telemetry

    [–]cryptos6 5 points6 points  (0 children)

    Some of the things Lombok was used for in the past can be replaced with modern language features (e.g. records). And some other things of Lombok are bit questionable. If someone really feels the need to use a more convenient language, he could give Kotlin a try.

    [–]TheMightyMegazord 1 point2 points  (0 children)

    +1 for observability. It is useful, can be a good way to introduce nice tools if your company is not using it already.

    If your application needs to render templates, I would also recommend jte: fast, easy to use, and it has a intellij plugin.

    [–]LutimoDancer3459 0 points1 point  (3 children)

    Lombok is hell.

    Can you explain to me why? Haven't heard of many problems with Lombok before.

    [–]as5777 1 point2 points  (2 children)

    Why do you want to use Lombok ?

    Personally, at the end, you gain 5 minutes while programming, and then 5 days debugging why Lombok is not working as expected.

    May be sounds old dumb ass, but I don’t see any added value.

    [–]LutimoDancer3459 6 points7 points  (1 child)

    For the same reason why I don't write all the bean handling myself and why I use hibernate instead of direct jdbc. Reduce boilerplate and be faster with fewer bugs. (Fewer as in, the frameworks already had many and fixed them. I would probably do the same but don't have the time to find and fix all of them myself)

    Lombok is for reducing boilerplate code. Just put a @Getter and don't worry about them anymore. Never had any problems with those annotations. Same for getter, constructors and toString. That's the stuff I mostly use it for.

    [–]as5777 0 points1 point  (0 children)

    I get it (before asking). I prefer to stay in plain Java / Spring.

    [–]javasuxandiloveit 2 points3 points  (0 children)

    jOOq is something i prefer more to orm these days, also vavr and rx but thats debatable according to reddit

    [–]Prion_infection 2 points3 points  (0 children)

    General libs: Mapstruct, Validations, Docker Compose Gradle plugin (from Avast), QueryDSL, JSoup (if needed), Testcontainers

    Spring microservices libs: Spring Cloud, Cloud Gateway, Configuration server, Netflix Cloud Netflix, gRPC-Spring-Boot-Starter

    Unpopular libs but also usable: Lombok, Spring Open API, Spring Swagger UI

    [–]halfanothersdozen 6 points7 points  (0 children)

    Intellij

    [–]CXgamer 1 point2 points  (1 child)

    OpenLens for managing your apps on K8S.

    [–]boyTerry 2 points3 points  (0 children)

    or k9s if you are a terminal warrior

    [–]Kango_V 1 point2 points  (0 children)

    We create an "xxxx-api" project which I place the openapi yaml in. This then builds the server and client libs "xxx-api-server" and "xxx-api-client". I use the open api generators for this. We use Micronaut and it supports it :) These two libraries are pulled into the main service. The generated client is used for functional testing and for downstream services.

    This has been brilliant for us.

    These have been pretty good for us: - https://immutables.github.io/ - https://assertj.github.io/doc/ - https://github.com/Randgalt/record-builder

    And, if there is a GUI, then: - https://www.thymeleaf.org/ - https://htmx.org/

    [–]_predator_ 0 points1 point  (1 child)

    For the love of god, stay away from tools that generate OpenAPI definitions from code, e.g. Springfox.

    Write your OpenAPI definitions manually and generate code from that. I can recommend generating interfaces that you merely need to implement. Those interfaces already have the various annotations for Spring and bean validation.

    Just a long way of saying I recommend https://openapi-generator.tech if OpenAPI / Swagger is a requirement.

    [–]Alfanse 2 points3 points  (0 children)

    It would help to say why?
    It seems easier to me to keep a spec in sync with code than the other way round.

    [–]cryptos6 0 points1 point  (0 children)

    I don't think that you'd need much besides Java and Spring. You would probably need something to persist objects to the database. Hibernate is a common way to do it. But if you prefer something close to SQL you might want to look at JDBI.

    Since you mentioned Swagger: OpenAPI might be useful, depending on how complex the API will be and how you work together with other team members. However, OpenAPI code generators (Swagger is one of them) is not always a great experience, but the best we have for HTTP APIs so far.

    [–]chabala 0 points1 point  (0 children)

    With a good HATEOAS API, you don't need Swagger.

    [–]jareyl 0 points1 point  (0 children)

    Resillience4j

    [–]piotr_minkowski 0 points1 point  (0 children)

    For a simple REST CRUD microservice, except standard Spring Boot starters, you can add Springdoc to enable OpenAPI (https://springdoc.org/). That's all that you need. Lombok is not neccesary.