Giter Club home page Giter Club logo

java-ddd-example's Introduction

☕🚀 Java DDD example: Save the boilerplate in your new projects

⚡ Start your Java projects as fast as possible

CodelyTV CI pipeline status

ℹ️ Introduction

This is a repository intended to serve as a starting point if you want to bootstrap a Java project with JUnit and Gradle.

Here you have the course on CodelyTV Pro where we explain step by step all this (Spanish)

🏁 How To Start

  1. Install Java 11: brew cask install corretto
  2. Set it as your default JVM: export JAVA_HOME='/Library/Java/JavaVirtualMachines/amazon-corretto-11.jdk/Contents/Home'
  3. Clone this repository: git clone https://github.com/CodelyTV/java-ddd-example.
  4. Bring up the Docker environment: make up.
  5. Execute some Gradle lifecycle tasks in order to check everything is OK:
    1. Create the project JAR: make build
    2. Run the tests and plugins verification tasks: make test
  6. Start developing!

☝️ How to update dependencies

  • Gradle (releases): ./gradlew wrapper --gradle-version=WANTED_VERSION --distribution-type=bin

💡 Related repositories

☕ Java

🐘 PHP

🧬 Scala

java-ddd-example's People

Contributors

angelenriquep avatar borjapazr avatar dependabot-preview[bot] avatar javiercane avatar mikybars avatar rgomezcasas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

java-ddd-example's Issues

Fix: compiling to jar

When generating the jar, the project does not find the database xml, because they recommend deploying the project using gradle and not the jar.

Error con hibernate usando docker JAR

Descripción

Estoy comenzando a aplicar DDD en un proyecto ya funcional. Hasta el momento logre hacer funcionar correctamente una simple búsqueda de datos en la BD implementado la abstracción de hibernate usando los archivo hbm.xml.

Al momento de intentar ejecutar el mismo en docker el mismo falla al buscar los resultados de la BD con el siguiente error:

company-notification | 2021-02-19 18:04:18.636 ERROR 1 --- [nio-8080-exec-4] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is com.remax.notification.aggregates.shared.domain.bus.query.QueryHandlerExecutionError: java.lang.IllegalArgumentException: Not an entity: class com.company.notification.aggregates.notification_type.domain.NotificationType] with root cause
company-notification | java.lang.IllegalArgumentException: Not an entity: class com.company.notification.aggregates.notification_type.domain.NotificationType
company-notification | at org.hibernate.metamodel.internal.MetamodelImpl.entity(MetamodelImpl.java:566) ~[hibernate-core-5.4.9.Final.jar!/:5.4.9.Final]
company-notification | at org.hibernate.query.criteria.internal.QueryStructure.from(QueryStructure.java:127) ~[hibernate-core-5.4.9.Final.jar!/:5.4.9.Final]
company-notification | at org.hibernate.query.criteria.internal.CriteriaQueryImpl.from(CriteriaQueryImpl.java:154) ~[hibernate-core-5.4.9.Final.jar!/:5.4.9.Final]

Posible causa

Estoy casi seguro que es por debido a la función searchMappingFiles que no encuentra los archivos de definición y al recuperar no encuentra una entidad para tales datos.

Config

DockerFile

FROM amazoncorretto:11
VOLUME /tmp
COPY build/libs/*.jar app.jar
ENTRYPOINT ["java","-jar","/app.jar"]

Prueba nro 1

Cambie el docker file al siguiente:

FROM amazoncorretto:11
VOLUME /tmp
COPY build/libs/*.jar app.jar
COPY src/main/resources/hibernate/NotificationType.hbm.xml /hibernate/NotificationType.hbm.xml
ENTRYPOINT ["java","-jar","/app.jar"]

Ademas de hacer hacer que el mapping buscara los archivos en la carpeta /hibernate/ lo cual soluciona el problema y confirma mis sospechas sobre que no encuentran esos archivos. Ahora solo me queda mejorar un poco la estructura y encuentre dinámicamente según el contexto a donde buscar los archivos

Solución (con posibles mejoras)

Moviendo los archivos hbm.xml a resources/db/hibernate y cambiando la función de mapping por la siguiente:

private List<Resource> searchMappingFiles() throws IOException {
        ClassLoader cl = this.getClass().getClassLoader();
        ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(cl);
        Resource[] resources = resolver.getResources("classpath:/db/hibernate/*.hbm.xml");
        return Arrays.asList(resources.clone());
}

Can't get the project up and running

Hi! I'm just trying to follow the 'how to start' section of the README.md but I've faced a couple of problems.

My Java version is 11.0.15 (since the README says to use the 11 version).

image

When i run make up for bringing up the Docker environment, everything works fine as you can see in the following screenshot.

image

But when I run make build for building and creating the project JAR, the tests throw a bunch of errors as you can see in the following screenshot that don't allow me to continue with the build.

image

Am I doing something wrong or missing something? Any kind of feedback would be appreciated. 🙏🏻

Porque NewCoursesNewsletterSender rompe los limites ?

Revisando un poco el codigo de NewCoursesNewsletterSender me doy cuenta de que rompe los limites al usar SearchLastCoursesQuery y CoursesResponse.

Incluso revisando el dominio de NewCoursesNewsletter, también conoce de application.

Lo que se menciona dentro del libro CleanArchitecture, en los capítulos 16, 17, 18. Es tratar de mantener capas verticales relacionados con lo que hace el sistema (casos de uso). Los casos de uso cambian por diferentes razones y a diferentes ritmos entre sí, por lo tanto, deben protegerse entre sí.

Me gustaría saber, si hay una razón del porque romper los limites en este componente, pues me encuentro estudiando todo esto y quería compartir mi preocupación.

Agregar retry and dead letter testing en rabbit mq

Actualmente la clase RabbitMqEventBusShould solamente comprueba si se publica y consume correctamente un evento.

Se puede agregar casos de test para los siguientes escenarios:

  • Comprobar si se dispara una exception al consumir eventos no existentes
  • Comprobar si se reintenta un evento
  • Comprobar se se envia la dead letter despues de reintentar varias veces.

error al ejecutar make run

FAILURE: Build failed with an exception.

* What went wrong:
Cannot locate tasks that match ':run' as task 'run' not found in root project 'java-dd-example'.

* Try:
> Run gradlew tasks to get a list of available tasks.
> For more on name expansion, please refer to https://docs.gradle.org/8.4/userguide/command_line_interface.html#sec:name_abbreviation in the Gradle documentation.
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.

HTTP request example

I have been able to learn CriteriaConverter and the parseFilter function but I cannot identify how to make an HTTp request on the GET / courses backoffice endpoint

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.