Category : spring

I try to dockerize my java spring application. In my build.gradle implementation ‘org.testcontainers:junit-jupiter’ implementation ‘org.testcontainers:postgresql’ In my test file: @SpringBootTest class ApplicationTests { @ClassRule public static PostgreSQLContainer postgreSQLContainer = new PostgreSQLContainer("postgres:11.1") .withDatabaseName("integration-tests-db") .withUsername("sa") .withPassword("sa"); static class Initializer implements ApplicationContextInitializer<ConfigurableApplicationContext> { public void initialize(ConfigurableApplicationContext configurableApplicationContext) { TestPropertyValues.of( "spring.datasource.url=" + postgreSQLContainer.getJdbcUrl(), "spring.datasource.username=" + postgreSQLContainer.getUsername(), "spring.datasource.password=" + postgreSQLContainer.getPassword() ..

Read more

Im getting the connection refused error, but in my eclipse it connects with no problem. I wonder if it is not possible to connect to a database that hasnt been dockerized also or if its possible what should I do? thise is my Dockerfile: FROM openjdk:11 EXPOSE 8080 ADD target/permisos.jar permisos.jar ENTRYPOINT ["java","-jar","/permisos.jar"] this is ..

Read more

I have an application based on java spring in kubernetes. For multipule environments I use spring profiles. But I need to rebuild my app for each environment using maven+docker to get the right config and push it into kubernetes. Here are my lines in pipeline: – mvn clean -Dspring.profiles.active=$ENV_PROFILE package – DOCKER_BUILDKIT=1 docker build –build-arg ..

Read more

If I run spring from fatjar, it uses spring serializer, which works (prescribed in producer settings, package org.springframework.kafka.support.serializer.JsonSerializer), message serialized without error, but if you try to run spring boot in a container, for some reason the settings don’t apply, the standard com.fasterxml.jackson.databind.JsonSerializer works, why is this happening? import org.springframework.kafka.support.serializer.JsonSerializer; import java.util.HashMap; import java.util.List; import ..

Read more

I have a few spring boot applications that I put in containers using Docker-compose. One of them needs to communicate with a MYSQL database that I run locally on my PC. In my applications.properties file I need to set an URL. Currently it looks like this: spring.datasource.url=jdbc:mysql://localhost:3306/test_database spring.datasource.username=root spring.datasource.password=root I know localhost won’t work because ..

Read more

I’m creating an application using angular for the frontend and spring boot for the backend. Evrything works well on my local machine. But for deployment, I choose to containerize each of them in separate Docker containers. The problem came into place when I tried to call the backend api form the angular application (displayed on ..

Read more