Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 12:43
    wilkinsona labeled #29583
  • 12:43
    wilkinsona unlabeled #29583
  • 12:43
    wilkinsona closed #29583
  • 12:43
    wilkinsona commented #29583
  • 12:43
    wilkinsona labeled #28188
  • 12:43
    wilkinsona labeled #28188
  • 12:43
    wilkinsona reopened #28188
  • 12:42
    wilkinsona commented #28188
  • 12:36
    wilkinsona commented #29571
  • 11:59
    wang-xiaowu commented #29571
  • 11:41
    wang-xiaowu commented #29571
  • 11:08
    wang-xiaowu commented #29571
  • 10:57
    ntinnemeier edited #29583
  • 10:57
    spring-projects-issues labeled #29583
  • 10:56
    ntinnemeier edited #29583
  • 10:55
    ntinnemeier opened #29583
  • 10:50
    wang-xiaowu commented #29571
  • 10:46
    ntinnemeier commented #28188
  • 10:46
    wang-xiaowu commented #29571
  • 10:43
    ntinnemeier commented #28188
@tul
@atulmundaware
Hi, i was working on resilience4j with springboot. but i was facing an issue where if i use @CircuitBreaker on a method its not working and if i add it over @GetMapping then it works. Can any one please help
resilience4j.circuitbreaker.instances.pocService.registerHealthIndicator=true
resilience4j.circuitbreaker.instances.pocService.eventConsumerBufferSize=10
resilience4j.circuitbreaker.instances.pocService.automaticTransitionFromOpenToHalfOpenEnabled=true
resilience4j.circuitbreaker.instances.pocService.failureRateThreshold=50
resilience4j.circuitbreaker.instances.pocService.minimumNumberOfCalls=5
resilience4j.circuitbreaker.instances.pocService.permittedNumberOfCallsInHalfOpenState=3
resilience4j.circuitbreaker.instances.pocService.slidingWindowSize=10
resilience4j.circuitbreaker.instances.pocService.waitDurationInOpenState=60s
resilience4j.circuitbreaker.instances.pocService.slidingWindowType=COUNT_BASED
management.health.circuitbreakers.enabled=true
management.endpoint.health.show-details=always

  @GetMapping("/retry")
  public BaseResponse pocRetry(HttpServletRequest request, HttpServletResponse response) {
    log.info("in poc retry poc resource");
    return getResponse(request, response);
  }

  @GetMapping("/retry-new")
  @CircuitBreaker(name = "pocService", fallbackMethod = "fallback")
  public BaseResponse pocRetryNew(HttpServletRequest request, HttpServletResponse response) {
    log.info("in poc retry poc resource");
    HttpEntity<SearchRequest> httpRequest = new HttpEntity<>(RestConstants.getJWTAuthHttpHeaders(false));
    log.info("Attempt no = {}", attempts++);
    ResponseEntity<BaseResponse> baseResponse = restTemplate
        .exchange(url + "/poc", HttpMethod.GET, httpRequest, BaseResponse.class);
    return baseResponse.getBody();

  }


  @SneakyThrows
  @CircuitBreaker(name = "pocService", fallbackMethod = "fallback")
//  @Retry(name = "poc-retry", fallbackMethod = "fallback")
  public BaseResponse getResponse(HttpServletRequest request, HttpServletResponse response) {
    HttpEntity<SearchRequest> httpRequest = new HttpEntity<>(RestConstants.getJWTAuthHttpHeaders(false));
    log.info("Attempt no = {}", attempts++);
    ResponseEntity<BaseResponse> baseResponse = restTemplate
        .exchange(url + "/poc", HttpMethod.GET, httpRequest, BaseResponse.class);
    return baseResponse.getBody();
  }

  public BaseResponse fallback(Exception e) {
    log.error("fallback-");
    BaseResponse response = new BaseResponse();
    response.setMessage("this is fallback response - profile-data-service is down");
    return response;
  }
retry-new api is working fine but retry api is not working
donahchoo
@donahchoo
Any thoughts on if the Spring team considers it correct behavior that slashes are not supported in PathElement regexes?
10 replies
EATONJIANGHAHAHA
@EATONJIANGHAHAHA
Is there any way a Spring-boot project accepts multiple command line arguments during runtime?
ABC奶油
@SaKiCake1
有中国人说话么0。0
有啊,第一天来这里~逛逛先! 哈哈哈哈~~~
Donald F Coffin
@dfcoffin

I am maintaining a Spring Boot 2.6.2 application with the following ServletWebFactory Bean:

@Bean
public ServletWebServerFactory servletContainer() {
TomcatServletWebServerFactory tomcat = postProcessContext(context) -> {
SecurityConstraint securityConstraint = new SecurityConstraint();
securityConstraint.setUserConstraint("CONFIDENTIAL");
SecurityCollection collection = new SecurityCollection();
collection.addPattern("/*");
securityConstraint.addCollection(collection);
context.addConstraint(securityConstraint);
}
};
tomcat.addAdditionalTomcatConnectors(new Connector[]{this.redirectConnector()});
return tomcat;
}

private Connector redirectConnector() {
    Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
    connector.setScheme("http");
    connector.setPort(8080);
    connector.setSecure(false);
    connector.setRedirectPort(8443);
    return connector;
}

Is there a "best practice" method to occomplish the same objective without having to code a Java Bean?

1 reply
Félix Roberto Aballí Morell
@felixaballi_gitlab
hi guys, where can i find some help for spring-data-mongodb ?
1 reply
Lukáš Vasek
@bilak
Hello, I'm using standard rest controller and inside response body I have OffsetDateTime. The problem is that on same entity for POST endpoint the date is returned only with milliseconds, however for GET also the nanoseconds are returned. Is there some configuration for this to unify it?
1 reply
SlawekNowy
@SlawekNowy
Question. I have two template pages /index and /login_test. The second one will replace the login page. Until then it's renamed. But login_test is unreachable; Thymeleaf doesn't pick up the template, while index works. What am I doing wrong? I'm using Spring Boot by the way.
login_test also uses some parts from index via th:insert.
1 reply
gopalsai
@gopalsai
image.png
5 replies
Hi, I am trying to Upgrade Sprinboot Version 1.2.4 to 1.4.1 Release and I am facing the following Error with snakeyaml 1.14 to 1.17
gopalsai
@gopalsai
image.png
@wilkinsona , Thank you for your reply
Please find the build.gradle, dependencies script in the above image. I am not specifying snakeyaml version anywhere…please guide
image.png
image.png
Based on te documentation, Springboot 1.4.1.RELEASE comes with SnakeYaml 1.17 Version and that is what I have in the External Libraries
gopalsai
@gopalsai
image.png
leoedeng
@leoedeng
@wilkinsona, got error using gradle with the just-released spring boot 2.6.3, which seems to be caused by spring-boot-loader-tools 2.6.3 not available in plugins.gradle.org
demo$ gradle tC
Configuration on demand is an incubating feature.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'demo'.
> Could not resolve all files for configuration ':classpath'.
   > Could not find org.springframework.boot:spring-boot-loader-tools:2.6.3.
     Searched in the following locations:
       - https://plugins.gradle.org/m2/org/springframework/boot/spring-boot-loader-tools/2.6.3/spring-boot-loader-tools-2.6.3.pom
     If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
     Required by:
         project : > org.springframework.boot:org.springframework.boot.gradle.plugin:2.6.3 > org.springframework.boot:spring-boot-gradle-plugin:2.6.3

* Try:
> 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

BUILD FAILED in 1s
2 replies
I was able to work around it with adding following code to settings.gradle:
pluginManagement {
    repositories {
        gradlePluginPortal()
        mavenCentral()
    }
}
but a vanilla gradle project generated with start.spring.io would fail to build
Attoumane
@akuma8

Hi booters,
I have a strange behaviour in this simple situation with @RestControllerAdvice:
I defined a custom exception, say:

@Getter
public class NotFoundException extends RuntimeException {

    private Object[] messageParams;

    public NotFoundException(String message) {
        super(message);
    }

    public NotFoundException(String messageCode, Object... messageParams) {
        super(messageCode);
        this.messageParams = messageParams;
    }
}

And my controller is:

@RestController
@RequestMapping(path = "entreprises", produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class EntrepriseApi {

    private final EntrepriseService entrepriseService;

    @GetMapping(path = "/{id}")
    public EntrepriseResponse getEntreprise( @PathVariable UUID id) {
        return entrepriseService.getEntreprise(id); // NotFoundException is thrown here if an entreprise does not exist
    }
}

The controller advice:

@RequiredArgsConstructor
@RestControllerAdvice(basePackageClasses = EntrepriseApi.class)
public class RestAdapterExceptionHandler extends ResponseEntityExceptionHandler {

    private final MessageUtils messageUtils;

    @ResponseStatus(HttpStatus.NOT_FOUND)
    @ExceptionHandler(NotFoundException.class)
    public ExceptionBody handleNotFoundException(NotFoundException ex) {
        return new ExceptionBody(ex.getMessage(), messageUtils.findMessage(ex.getMessage(), ex.getMessageParams()), HttpStatus.NOT_FOUND.value());
    }
}

The problem is that ExceptionBody handleNotFoundException(NotFoundException ex) method is not invoked when a NotFoundException is thrown.
What did I miss?
Thanks

Spring Boot version is 2.5.5
Attoumane
@akuma8
It seems like Spring MVC internal exceptions are well catched but mine are not.
Kirill Marchuk
@62mkv

Hi. I was always curious, is it safe to write spring Configuration like that?

  @Bean
  public ProducerFactory<String, String> producerFactory(KafkaContainerFactoryConfig config) {
    return new DefaultKafkaProducerFactory<>(
        config.producerConfigs(), new StringSerializer(), new StringSerializer());
  }

  @Bean
  public KafkaTemplate<String, String> kafkaTemplate(KafkaContainerFactoryConfig config) {
    return new KafkaTemplate<>(producerFactory(config));
  }

would not 2 producerFactories be created in such case? or does Spring allow for some kind of magic to avoid that? or would it be fine to have 2 factories, one as a bean and the other as a "source" for KafkaTemplate (in this case) ?

1 reply
Occasionally such style is present even in Spring documentation (which, I guess, is where this code was copy-pasted from)
Andy Wilkinson
@wilkinsona
@akuma8 I can't see anything that you've missed. I tried copying your code into a new Spring Boot 2.5.9 project, modifying it slightly to remove the use of MessageUtils and the other classes that you haven't shared. The controller advice is called as expected when the NotFoundException is thrown. I'm happy to dig a bit more, but I'd need to complete yet minimal example that reproduces the problem to be able to do so.
2 replies
Piotr Joński
@sta-szek

hi guys i have question about more complex configuration.
my case is that i have 2 starters, starter-db and starter-tenant-management.
starter-db provides interface TenantProvider and default implementation SchemaBasedTenantProvider

STM provides @Primary ActiveTenantProvider implementation as well.

STM depends on SDB.
SDB DOES NOT depend on STM -> no compile class access
i use spring boot 2.6.2

now, i have custom class for DB migrations, to load less beans than usually needed:

@SpringBootConfiguration
// starter-tenant-management configuration is not a compile time dependency (to avoid circular dependency)
// we need ActiveTenantProvider to perform migration only for active tenants
@ComponentScan(basePackages = {"springboot.starter"},
        resourcePattern = "springboot.starter.tenantmanagement.infrastructure.configuration.TenantProviderAutoConfiguration.class")
@Import({
        MonitoringConfiguration.class,
        LiquibaseAutoConfiguration.class,
        PersistenceAutoConfiguration.class,
        HikariDataSourceBeanPostProcessor.class,
        DataSourceAutoConfiguration.class,
        MetricsAutoConfiguration.class,
        CompositeMeterRegistryAutoConfiguration.class,
        ContextConfiguration.class,
        HibernateJpaAutoConfiguration.class
})
@ConditionalOnNotWebApplication  // Otherwise, the included spring configuration is added to a microservice's application context
@Profile(Profiles.MIGRATIONS) // To avoid using this application by tests for bootstrap
public class DatabaseMigrationsConsoleApplication implements CommandLineRunner {

and the class TenantProviderAutoConfiguration is not being called in debug mode, sounds like @ComponentScan do not work.

what is the best way to handle such dependencies?

2 replies
learningdeveloper2021
@learningdeveloper2021

Approaches to handle 10 million records of 10 tables each with several joins

I have 10 million records of 10 tables each with several joins. I am looking for the best alternative or DB assign or approach to read the records very quickly that is the query should be fast.

option#1 - normalize the tables, don't go for joins unnecessarily
option#2 - add all the columns in 1st query where multiple times the
where conditions will be used in the looping construct
option#3 - go for nosql database instead of mysql

Please advise

Thanks

Salman khandu
@salman-khandu

We have an application that has two dependencies web as well as webflux. All our code is non-blocking except database call( one read call).
Is there any way to run with non-blocking without removing spring-boot-starter-web dependency ( as we have used @ControllerAdvice so if we try to remove web dependencies there will be more code changes)

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
Thank you

3 replies
Adrian Soria
@adrianSoria
Is the RestTemplate deprecated? We are only using synchronous calls. Webclient is newer but webflux is needed. We want to avoid to use webflux.
7 replies
Masinac
@Masinac

After upgrading to Spring Boot 2.6.3 I'm getting cyclic dependency error, which I'm not sure how to fix:

Description:
The dependencies of some of the beans in the application context form a cycle:
┌─────┐
| securityConfiguration
↑ ↓
| org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration
└─────┘

4 replies
mpretzer
@mpretzer

Hi,

I have an application with default settings defined in /src/main/resources/application.properties (i.e. the classpath root) und custom settings in the file system in $PWD.

This works fine when starting the app from an executable jar. When I use layertools to extract the app (java -Djarmode=layertools -jar application.jar extract), the settings from the classpath root are ignored.

Is this expected behaviour?

17 replies
Josh Wein
@JoshWein
Is it possible to have Spring Boot also collect JFR metrics or are those usually looked at separately? We have Spring exporting all our metrics into a micrometer MetricRegistry and I was hoping to ship JFR metrics that way as well to be able to analyze all those metrics in the same place. It seems like JFR is mainly used standalone though
Robert Wiesner
@rowi1de
What's the best way to handle java.lang.OutOfMemory Error?
Usually I let it propagate to the JVM/Docker container so the instance get’s killed / restarted.
In my current application this error get’s caught in the Tomcat server of spring boot and I don't know why … any clues?
NARASIMHA RAO
@_sunkara_twitter
Hello all
Even though we set the the props like below still we are getting 413 largepayload issue with jacsonmapping exception
spring.servlet.multipart.enabled=true
spring.servlet.multipart.max-file-size=500MB
spring.servlet.multipart.max-request-size=500MB
Holothuroid
@Holothuroid
Hi. I'd like to use actuator httptrace. Is there a way to one-way hash principal names? Data protection says usernames should not stored plain for analytics purposes.
1 reply
James Howe
@OrangeDog
This table doesn't make much sense
https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0.0-M1-Configuration-Changelog
The columns seem to be "default value" and "description" rather than "replacement" and "reason"
James Howe
@OrangeDog

I also cannot get the IDEA-Maven integration working, because IDEA apparently cannot run under Java 17 yet, and the new Spring Boot Maven plugin doesn't work on Java 11.

org/springframework/boot/maven/BuildInfoMojo has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0

Andy Wilkinson
@wilkinsona
@OrangeDog Thanks. I’ve opened spring-projects/spring-boot#29563 for the change log.
If there isn’t an issue already, it would be worth opening one with JetBrains for the Maven integration problem. Unfortunately, 3.0 is pretty bleeding edge at the moment for exactly this sort of reason. There’s still almost a year for the ecosystem to catch up though.
James Howe
@OrangeDog
It may be there's an option I'm not seeing to run maven operations with a separate JVM to what the IDE is running in.
Philipp Paul
@philurlaub
Hi hi, I have a question to the WebTestClient. By default it seem to use WiretapClientHttpRequest with a WiretapRecorder for the request body. I'm currently writing a controller test for a POST that is streaming a large request body. With the WiretapRecorder active, this means that it is stored in memory and at some point leading to out of heap space exception. How can I configure the webTestClient to use for example ReactorClientHttpRequest which is used by the default webClient (not in a test context) or disable the wiretapRecorder?
3 replies
Xatenev
@Xatenev
Hello, is there any way to automatically autowire all dependencies in a spring boot test?
1 reply
Instead of manually specifying them all in the @SpringBootTest(classes = []) annotation?
I have an integration test with a ton of dependencies...
peterek333
@peterek333
image.png
Hi, can I use ObjectFactory again? About my case - I implemented custom scope and overrided get method has passed objectFactory to instantiate bean. It is a different object (of the objectFactory) on each call. Maybe objectFactory is immutable and contains "snapshot" of some data, for example properties from Spring? So if I will store one objectFactory and reuse to recreate bean everytime when properties was changed - I will be using snapshot with old properties?
Virtual Space Snapshot
@virtualspacesnap

Hi...
In my project customer had 1.5.22.Release version of spring boot and now they want to migrate to 2.5.8

is there any guideline or check list for a seamless migration

1 reply
Even Lislebø
@evenlis
hiya. Does anyone know whether spring-boot-actuator supports kotlin reactor coroutines? I'm having a hard time finding anything on it
1 reply