Issue When trying to just make sure the connect is working, this error arises. Error that pops up This is the connect string, Connection string This is my aapp.properties, spring.data.mongodb.uri=mongodb+srv://jamescervamtes:jamescervantes@theshop.rmeawrn.mongodb.net/TheShop spring.data.mongodb.database=TheShop I tried everything, and I am just expecting for
Continue readingTag: spring-boot
How to create bean based on property in springboot
Issue I have two beans in my application configuration. I would like to enable only one bean based on property, Can we make bean conditional based on property ? Ex: Let say if I have this property enable.userconnection: true, I
Continue readingSpring Data Elasticsearch (4.x) – Using @Id forces id field in _source
Issue Summary Recently we upgraded to Spring Data Elasticsearch 4.x. Part of this major release meant that Jackson is no longer used to convert our domain objects to json (using MappingElasticsearchConverter instead) [1]. This means we are now forced to
Continue readingJava – Proper Way To Initialize an Autowired Service
Issue I have inherited a springboot application. This application has a service similar to the following: @Service public class MyService { String param1 = ""; String param2 = ""; public void doStuff() { // do stuff assuming the parameters param1
Continue readingSpringBoot with Thymeleaf – css not found
Issue First to say is that I’ve been searching for a solution for a while now and I’m quite desperate now. I cannot get the css file to be accessible from html page when run by Spring Boot. html.file <html
Continue readingAccess to XMLHttpRequest at 'http://localhost:8080/blog/updatePost/2' from origin 'http://localhost:3000' has been blocked by CORS policy:
Issue Even though I used @CrossOrigin annotation this error still appears. Spring boot app is running on 8080 port and react app is running on 3000 port. Error: If further information is needed, please let me know. Solution I assume
Continue readingWhy are my Thymeleaf Path variables breaking my HTML?
Issue I have two similar controller methods that I’m using to test the @PathVariable annotation with: @RequestMapping( value = "/1", method = {RequestMethod.GET}) public String two(Model model) { model.addAttribute("category", "acategory"); model.addAttribute("subCategory", "placeholder"); return "homePage"; } @RequestMapping( path = "/{category}/{subcategory}", method
Continue readingCould not fetch model of type 'BuildEnvironment' using Gradle distribution
Issue I’m getting the below error when I have imported a gradle project and tried refreshing it. I’m new to gradle and using gradle wrapper. also, the gradle distribution exists in the repository. Could not fetch model of type ‘BuildEnvironment’
Continue readingHow to execute a Spring Batch job from a Spring Boot app
Issue I have two spring apps. First one is a Spring Boot (app A) and the other is a standalone Spring Batch (app B) app. Usually, I am using a script to execute the Spring Batch (app B) jar and
Continue readingHow to add a bean in SpringBootTest
Issue The question seems extremely simple, but strangely enough I didn’t find a solution. My question is about adding/declaring a bean in a SpringBootTest, not overriding one, nor mocking one using mockito. Here is what I got when trying the
Continue readingHow to point a single spring actuator endpoint to the root ("/")
Issue I have a requirement to expose a health endpoint on the root path on the specific port. However, root path is reserved for the actuator endpoints overview and I could not find a way to overwrite that overview functionality
Continue readingSpring data jpa specifications and projections error
Issue I am getting below error when I use (https://github.com/pramoth/specification-with-projection) Caused By: org.springframework.data.mapping.PropertyReferenceException: No property findOne found for type <Entity class> any idea why its throwing this exception? Solution Looks like you are using incorrect Spring Data version. This library
Continue readingWhen and where to use JUnit, Mockito and Integration testing in Spring Boot Application?
Issue I’m very novice to Unit Testing, I have created a Spring Boot Application and now I want to do some testing what’s confusing me is where to use what e.g. I have classes and interfaces Controllers, Service, Repository I
Continue readingSwagger-ui.html is giving blank page
Issue When I am trying to enable swagger in my spring boot application, it is showing blank page. I am using url https://localhost:8080/context-path/swagger-ui/ I am able to get the JSON data for url https://localhost:8080/context-path/v2/api/docs I am not getting where this
Continue readingShedlock integration with Cassandra – CqlSession – table can not be null
Issue I am trying to integrate shedlock in my spring boot project using a cassandra db. But I am getting the below error on application startup. 2022-11-18 17:35:29,162 [main] ERRR o.s.boot.SpringApplication – Application run failed org.springframework.beans.factory.BeanCreationException: Error creating bean with
Continue readingSpring Cloud APIGW, Spring Boot and OpenAPI issue – CORS issue
Issue I am using Spring Boot and Microservices stack using Spring Cloud APIGW. I am using the same code mentioned here: https://piotrminkowski.com/2020/02/20/microservices-api-documentation-with-springdoc-openapi/ When I hit any endpoint, I don’t see response is coming and getting below error. Access to fetch
Continue readingHow to add requestHeader to the generated interface with openapi-generator-maven-plugin
Issue I am using openapi-generator-maven-plugin to generate the server code for a springboot application. However I can’t figure out a easy way to generate the @RequestHeader("header") in the interface. Here is the plugin configuration: <plugin> <groupId>org.openapitools</groupId> <artifactId>openapi-generator-maven-plugin</artifactId> <!– RELEASE_VERSION –>
Continue readingSpring custom configuration annotation
Issue I’m trying to create a Annotation to enable custom Kafka configuration to construct a commons lib. My idea with this aproach is turn easy kafka configuration for all my apps, removing all boilerplate configurations. So I want to annotate
Continue readingLog values of query parameters in Spring Data R2DBC?
Issue In Spring Data R2DBC I can log SQL queries by using logging.level.org.springframework.data.r2dbc=DEBUG in the application.properties. However, this doesn’t log the actual values that are bound as query parameters. How can I log the actual values of query parameters in
Continue readingSpring Security exposing AuthenticationManager without WebSecurityConfigurerAdapter
Issue I’m trying incoming Spring Boot 2.7.0-SNAPSHOT, which uses Spring Security 5.7.0, which deprecate WebSecurityConfigurerAdapter. I read this blog post, but I’m not sure to understand how I can expose the default implementation of AuthenticationManager to my JWT authorization filter.
Continue readingSpring Security Resource Server throws "SpelEvaluationException: EL1011E"
Issue I’m setting up a Resource Server with Spring Security 5.7.3 which authenticates against a Spring Authorization Server 0.3.1. I followed the instructions on https://docs.spring.io/spring-security/reference/servlet/oauth2/resource-server/jwt.html by setting the isser uri (which seems to work properly) but I always get an
Continue readingHow to fetch data as pageable with custom query in Jpa without IllegalArgumentException?
Issue I am fetching data with custom query by applying the way on this post. And here is my repository method that returns a page sorted by distance which is a mysql function: @Query(value = "SELECT *, ST_Distance_Sphere(ST_GeomFromText(?1, 4326), location)
Continue readingAxios post multipart with object
Issue Here is my spring boot endpoint to post file and object in one request @PostMapping( value = ["/add"], consumes = [ MediaType.MULTIPART_FORM_DATA_VALUE, MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_FORM_URLENCODED_VALUE, MediaType.APPLICATION_OCTET_STREAM_VALUE ] ) fun addUser( @RequestPart("user") user: UserDTO, @RequestPart("file") file: MultipartFile, ): Long = userService.addUser(user,
Continue readingSpring @configurable NullPointerException, @autowired service is null
Issue I’m trying to use @configurable in spring to use a @autowired service in a non bean class I create. It doesn’t want to work anymore whatever I try. Can someone tell me what I’m doing wrong? (I did some
Continue readingSpring @configurable NullPointerException, @autowired service is null
Issue I’m trying to use @configurable in spring to use a @autowired service in a non bean class I create. It doesn’t want to work anymore whatever I try. Can someone tell me what I’m doing wrong? (I did some
Continue reading404 error on logout with WAR exploded to Tomcat
Issue My application works fine when I use embedded Tomcat (with IntelliJ) but when I deploy WAR file on Tomcat 8 one of my URLs response with 404 (I can sign in into my application but logout with URL responses
Continue readingHow to create immutable and singleton class in Spring boot?
Issue I have a person model class that needs to be immutable and singleton. I need to autowire from my service class but getting an error. So is there any way to create a singleton immutable class in spring boot?
Continue readingHikariPool-1 – Exception during pool initialization
Issue I’m deploying Spring-Boot4 project and I have got an error called HikariPool-1 – Exception during pool initialization. 2019-07-05 11:29:43.600 INFO 5084 — [ main] org.hibernate.Version : HHH000412: Hibernate Core {5.3.10.Final} 2019-07-05 11:29:43.600 INFO 5084 — [ main] org.hibernate.cfg.Environment :
Continue readingFactory method 'jwtAccessTokenConverter' threw exception; nested exception is java.lang.IllegalArgumentException:
Issue It’s an error that comes out during spring build. I changed the difference from the existing source code to mariaDB -> mysqlDB. I wonder why this error is coming out. org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerEndpointsConfiguration’: Invocation of
Continue readinghow can application yaml value inject at runtime in spring boot?
Issue I want to change the value of application.yaml at loading time. ex) application.yaml user.name: ${name} Here, I want to put this value by calling an external API such as a vault, rather than a program argument when the jar
Continue readingJDK 17 spring boot Unable to make private java.time.LocalDateTime
Issue I have private LocalDateTime lastModifiedDate property in the simple mongodb entity. Run application with latest 2.5.5 and openjdk 17 Following exeptions I have with date time Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make private java.time.LocalDateTime(java.time.LocalDate,java.time.LocalTime) accessible: module java.base does not
Continue readingSpring Boot/Gradle/Logback: bootRun fails with "Failed to instantiate [ch.qos.logback.classic.LoggerContext]": java.lang.AbstractMethodError:
Issue In a new Spring Boot application, when I gradle bootRun, I see this error: Failed to instantiate [ch.qos.logback.classic.LoggerContext] Reported exception: java.lang.AbstractMethodError: ch.qos.logback.classic.pattern.EnsureExceptionHandling.process(Lch/qos/logback/core/Context;Lch/qos/logback/core/pattern/Converter;)V at ch.qos.logback.core.pattern.PatternLayoutBase.start(PatternLayoutBase.java:86) at ch.qos.logback.classic.encoder.PatternLayoutEncoder.start(PatternLayoutEncoder.java:28) at ch.qos.logback.classic.BasicConfigurator.configure(BasicConfigurator.java:50) at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:164) at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:85) at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:55) at org.slf4j.LoggerFactory.bind(LoggerFactory.java:150) at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:124) at
Continue readingHow to kill Java thread when it is finished?
Issue First time I am working with threads in spring boot webapp and when I do debugging then I see thread names are increasing like Thread-1, Thread-2… for every call method so I thought that the program is not killing
Continue readingLog Springboot classes (like DefaultMessageListenerContainer) logs to custom file
Issue I am facing one problem to log DefaultMessageListenerContainer.java (which is as Springboot class) error logs in a custom file using Log4j2 configuration. Below is the configuration setup in Log4j2.xml file: <Logger name="org.springframework.jms.listener.DeafultMessageListenerContainer" level="error"> <AppenderRef ref="customErrorFile"> </Logger> But still I
Continue readingis there any library or solution for spring response with long time needed job
Issue Some process in my project needed a few minutes(1~10min). and I provide the result of this process using spring boot web. so my API have to return the response with status(queueing/running/finished/failed). so I made kind of this attributes implement
Continue readingHow to implement Long Polling REST endpoint in Spring Boot app?
Issue Would you be so kind as to share any up-to-date manual or explain here how to implement a REST Long Polling endpoint with the latest Spring (Spring Boot)? Everything that I’ve found by this time is quite out-dated and
Continue readingHttp error code 403 after deploying to Firebase Hosting
Issue I created a simple Spring Boot application which I host on Heroku. I access this backend application with a Flutter Web client. When I run the Flutter Web client locally on my machine everything works like a charm until
Continue readingMap Nested elements – Mapstruct
Issue I’m trying to map following source classes to target class using MapStruct. Target Classes : public class Response { private List<Customer> customer = new ArrayList<Customer>(); } public class Customer { private String customerId; private List<Product> products = new ArrayList<Product>();
Continue readingCan a spring boot @RestController be enabled/disabled using properties?
Issue Given a “standard” spring boot application with a @RestController, eg @RestController @RequestMapping(value = “foo”, produces = “application/json;charset=UTF-8”) public class MyController { @RequestMapping(value = “bar”) public ResponseEntity<String> bar( return new ResponseEntity<>(“Hello world”, HttpStatus.OK); } } Is there an annotation or
Continue readingSpring Boot Cache SpEL (#result) Returns Null
Issue I have a Spring Boot RESTful API to receive and send SMS to clients. My application connects to our local SMS server and receives and pushes SMS to clients via mobile operators. My application works well. But I wanted
Continue readingDisable HTTP cache in WebFlux
Issue In Spring Boot MVC app I disable HTTP cache this way: WebContentInterceptor cacheInterceptor = new WebContentInterceptor(); cacheInterceptor.setCacheSeconds(0); cacheInterceptor.setUseExpiresHeader(true); cacheInterceptor.setUseCacheControlHeader(true); cacheInterceptor.setUseCacheControlNoStore(true); registry.addInterceptor(cacheInterceptor); How to do it in Spring Boot WebFlux app? Solution If you’re using Spring Boot and you’d like
Continue readingHow to hide endpoints from OpenAPI documentation with Springdoc
Issue Springdoc automatically generates a API documentation for all handler methods. Even if there are no OpenAPI annotations. How can I hide endpoints from the API documentation? Solution The @io.swagger.v3.oas.annotations.Hidden annotation can be used at the method or class level
Continue readingHow to hide endpoints from OpenAPI documentation with Springdoc
Issue Springdoc automatically generates a API documentation for all handler methods. Even if there are no OpenAPI annotations. How can I hide endpoints from the API documentation? Solution The @io.swagger.v3.oas.annotations.Hidden annotation can be used at the method or class level
Continue readingHow to ask Swagger UI to add bearer token field for each endpoint globally?
Issue Because of the issue described here I am migrating to Springdoc. And now in Swagger UI I don’t have a field for bearer token for each endpoint but it is expected because those endpoints are secured. I have the
Continue readingHow to ask Swagger UI to add bearer token field for each endpoint globally?
Issue Because of the issue described here I am migrating to Springdoc. And now in Swagger UI I don’t have a field for bearer token for each endpoint but it is expected because those endpoints are secured. I have the
Continue readingHow to customize Swagger Top Bar
Issue I am using a yaml file to control the content on my swagger page for my project. I am able to get nearly everything to look correct excepting I want to get the top bar to have the Select
Continue readingOpenAPI & spring-doc not finding all mappings in a controller class
Issue This is a bit weird. springdoc-openapi-ui v1.2.32, the generated docs contain only a few of the mappings within a controller. Example: @Operation( summary = "Foo", description = "Foo" ) @PostMapping(path="/v1/foo") public ResponseEntity<ResponseObject> postFoo(@RequestBody FooRequestObject searchRequest, HttpServletRequest request){ … }
Continue readingHow to use Property placeholders in .yml file
Issue I am working with Java and spring boot. I was wondering how to add Property placeholders into .yml files. I’ve found some crisp examples but I am not sure where are the Property placeholders are being instantiated in. Is
Continue readingSpring Boot – Different systems( eureka , zuul, ribbon, nginx,) used for what?
Issue I have been working with spring and now would like to learn spring boot and microservices. I understand what microservice is all about and how it works. While going through docs i came across many things used to develop
Continue readingOverride spring bean without an alias that is also the parent
Issue I have a bean in module1-spring.xml– <bean id=”parent” class=”com.Parent”/> <bean id=”service” class=”com.Service”> <property name=”parent” ref=”parent”/> </bean> I want to override the bean in module2-spring.xml– <bean id=”child” class=”com.Child” parent=”parent”/> I want child to be passed in service instead of parent.
Continue readingOverride spring bean without an alias that is also the parent
Issue I have a bean in module1-spring.xml– <bean id=”parent” class=”com.Parent”/> <bean id=”service” class=”com.Service”> <property name=”parent” ref=”parent”/> </bean> I want to override the bean in module2-spring.xml– <bean id=”child” class=”com.Child” parent=”parent”/> I want child to be passed in service instead of parent.
Continue readingLooking for an alternative of retryWhen which is now Deprecated
Issue I’m facing an issue with WebClient and reactor-extra. Indeed, I have the following method : public Employee getEmployee(String employeeId) { return webClient.get() .uri(FIND_EMPLOYEE_BY_ID_URL, employeeId) .retrieve() .onStatus(HttpStatus.NOT_FOUND::equals, clientResponse -> Mono.empty()) .onStatus(HttpStatus::is5xxServerError, clientResponse -> Mono.error(new MyCustomException(“Something went wrong calling getEmployeeById”))) .bodyToMono(Employee.class)
Continue readingHow do I set Content type for Spring Webclient to "application/json-patch+json"
Issue I am trying to make a patch rest request to another API that accepts content type "application/json-patch+json". I am using Spring’s webclient but I have not been able to get it to work. I keep getting "415 Unsupported media
Continue readingReturn the complete response using Spring WebClient
Issue I have the following code public ClientResponse doGet(HttpServletRequest request, URI uri) { return webClient.get() .uri(uri.toASCIIString()) .headers(headers -> headers.putAll(processRequest(request)) .exchange() .block(); } But when I try to return this ClientResponse through the RestController as follows, @GetMapping @ResponseBody public ClientResponse doGet(HttpServletRequest
Continue readingSpring WebFlux – a question about duplicating method invocation
Issue I’ve created a synthetic application using Spring Reactive framework to investigate caching mechanics, that is proposed with Webflux. What I’ve noticed, is that when I use a Webclient, that addresses to a third party URL, a method that uses
Continue readingHow to print raw HTTP Request and HTTP Response with Spring 5 Webclient?
Issue Spring MVC allows for logging of request and response body to allow for easier debugging and verification of message content. This is required for my project for auditing purposes, the log messages MUST contain the full request and response
Continue readingSpringboot WebClient Broken in docker container
Issue Iv created two Springboot applications that Iv dockerized and created local containers. When I run the applications locally through intellij on my machine they work ok. Application A, on localhost:8080 has a Spring WebClient with a baseUrl localhost:8081 configured
Continue readingHow can I save cookies between Spring WebClient requests?
Issue I would like to use Spring Boot WebClient in my project to access a REST-API. The first request performs the login into the REST-API and receives a cookie as response. This cookie is used as an "API-Token" for all
Continue readingHow to use WebClient to execute synchronous request?
Issue Spring documentation states that we have to switch from RestTemplate to WebClient even if we want to execute synchronous http call. For now I have following code: Mono<ResponseEntity<PdResponseDto>> responseEntityMono = webClient.post() .bodyValue(myDto) .retrieve() .toEntity(MyDto.class); responseEntityMono.subscribe(resp -> log.info(“Response is {}”,
Continue readingSalesforce REST api using reactor With Spring WebClient
Issue I tried to connect Salesforce from Spring boot webclient. I have the JWT token with the below code String header = "{\"alg\":\"RS256\"}"; String claimTemplate = "'{‘\"iss\": \"{0}\", \"sub\": \"{1}\", \"aud\": \"{2}\", \"exp\": \"{3}\", \"jti\": \"{4\"’}’"; try { StringBuffer token
Continue readingHow to deal with different JSON Response in Spring
Issue I’m using Spring WebClient to make REST requests. I’ve created POJO’s to store the JSON properties but there’s a problem. If a word on the API I’m using doesnt exist, It returns an array of words [ "testified", "the
Continue readingSpring WebClient POST and Content Length Header for application/x-www-form-urlencoded
Issue I am using Spring WebClient and Spring Boot 2.3.5.RELEASE to POST a request to a site that wants a Content Type of application/x-www-form-urlencoded. It keeps failing because the Content-Length header is not set. I can set that in the
Continue readingSpring WebClient – how to access response body in case of HTTP errors (4xx, 5xx)?
Issue I want to re-throw my exception from my “Database” REST API to my “Backend” REST API but I lose the original exception’s message. This is what i get from my “Database” REST API via Postman: { “timestamp”: “2020-03-18T15:19:14.273+0000”, “status”:
Continue readingSpring WebClient Post body not getting passed
Issue I am trying to use WebClient to Post a loan object to another microservice which saves this object in a DB. So theoretically the body (JSON loan object) should just be passed on to the API of the DB
Continue readingCorrect dependencies to use when using WebClient with Spring MVC
Issue I’m using Spring MVC to develop some controllers. I would like to write some scenario integration tests which will involve calling multiple controllers of my application. Normally I would have just used RestTemplate within these tests but the documentation
Continue readingWebclient maven Dependency errors
Issue I am getting a NoClassDefFoundError on the line where I try to create WebClient instance using ‘create‘. Tried builder() but still the same thing. Please tell me what’s wrong with the dependencies which I have added and how this
Continue readingHow many instance(s) of @Autowired "prototype" bean is(are) created during the usage of a @Component
Issue I have a Managerclass annotated with @Component
 and @Scope @Component
 @Scope(value = "prototype")
 public class Manager { … } So I expect a new instance of the Manager bean will be created each time the bean is requested. Then
Continue readingsingleton at the boot of application
Issue I’m creating a small game where I would like to have a game room and a bunch of games in the game room. This would be a spring boot application. So I was thinking of starting the GameRoom at
Continue readingAngularJS 1.6 Upgrade code to login no longer working with REST?
Issue I had a project using AngularJS 1.5.8 and the login method worked as followed: $scope.login = function() { // creating base64 encoded String from user name and password var base64Credential = btoa($scope.username + ‘:’ + $scope.password); // calling GET
Continue readingPagination with Sorting doesn't work in ORACLE database with Hibernate
Issue I’m using spring jpa with hibernate. When I use the pagination with sorting (typically in tables) the Oracle10gDialect generates the following SQL select row_.*, rownum rownum_ from ( select table_.tablefield1, table_.tablefield2, table_.tablefield3… from table table_ where <condition> order by
Continue readingSpring boot JPA save manytomany relationship
Issue I am trying to store a manytomany relationship but it not stores the relationship. The following code has generated 3 tables. Soldier, medal and soldier_medals. The service just make a call to a CRUD Interface with save(soldier). It stores
Continue readingSpring Boot @ComponentScan not working via custom annotation in multi module project
Issue I have a multi module project (gradle) with following structure: Root project ‘mp-search’ +— Project ‘:analyzer’ +— Project ‘:common’ | \— Project ‘:common:es-model’ … Description: :analyzer: contains a spring boot application Contains @SpringBootApplication and all other needed dependencies (Web,
Continue readingConsider defining a bean of type 'service' in your configuration [Spring boot]
Issue I get error when I run the main class. Error: Action: Consider defining a bean of type ‘seconds47.service.TopicService’ in your configuration. Description: Field topicService in seconds47.restAPI.topics required a bean of type ‘seconds47.service.TopicService’ that could not be found TopicService interface:
Continue readingWhy spring transactional executes code after repository save exception?
Issue Using the annotation @Transactional spring executes the function past the repository save error to the following lines that shouldn’t have been executed!! Example: Using @Transactional on method iEmployeeRepository.save(employee); <<– Error occurs here System.out.println("Hello"); <<– This line still gets executed
Continue readingSpring Cloud Maven dependency conflict "NoSuchMethodError"
Issue I’m currently working on Spring Cloud and Spring Data, but I got an error when I’m trying to run my program Error starting ApplicationContext. To display the auto-configuration report re-run your application with ‘debug’ enabled. 2017-05-19 10:20:35.886 ERROR 55581
Continue readingAWS DynamoDb fails when accessed from EC2 instance with Spring data
Issue Hy guys, when I run my Spring Boot 2 project from my local machine (Ubuntu) is all fine but when I tried to access DynamoDb tables from my Spring Boot 2 project running on EC 2 instance I received
Continue readingTable 'DBNAME.hibernate_sequence' doesn't exist
Issue I have a SpringBoot 2.0.1.RELEASE application using spring data / jpa <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> But when I do an update in the Amazon Aurora DB, I got this error: 2018-04-13 09:20 [pool-1-thread-1] ERROR o.h.id.enhanced.TableStructure.execute(148) – could not read
Continue readingSpring-Data JPA CrudRepository returns Iterable, is it OK to cast this to List?
Issue I’m writing a code-gen tool to generate backend wiring code for Spring-boot applications using Spring-Data-Jpa and it’s mildly annoying me that the methods in the CrudRepository return Iterable rather than List, as iterable doesn’t provide quite enough functionality, but
Continue readingException about the lack of primary attribute in an entity
Issue I am a newbie with spring boot and Cassandra and I’m trying to connect both to build an API. The project is written in Scala to learn from this too. This is main application: object Application { def main(args:
Continue readingIgnore field for query in spring-r2dbc
Issue I am using spring r2dbc and ReactiveCrudRepository in spring webflex applicaition. I have a field which I need to ignore for when select query is generated ( in Controller code is r2dbcEntityTemplate.select(Tenant.class) ). I try to using @Transient ,But
Continue readingNoHostAvailableException: All host(s) tried for query failed
Issue When I connected a single node cassandra it is working fine. Where as I connected a three node cluster (10.20.12.20, 10.20.12.21, 10.20.12.22) it is throwing below error. Why it is trying to connect localhost ? Caused by: com.datastax.driver.core.exceptions.NoHostAvailableException: All
Continue readingSpring Boot 2.7.1 with Data R2DBC findById() fails when using H2 with MSSQLSERVER compatibility (bad grammar LIMIT 2)
Issue I’m upgrading a Spring Boot 2.6.9 application to the 2.7.x line (2.7.1). The application tests use H2 with MS SQL Server compatibility mode. I’ve created a simple sample project to reproduce this issue: https://github.com/codependent/boot-h2 Branches: main: Spring Boot 2.7.1
Continue readingSpring Boot & MongoDB how to remove the '_class' column?
Issue When inserting data into MongoDB Spring Data is adding a custom “_class” column, is there a way to eliminate the “class” column when using Spring Boot & MongoDB? Or do i need to create a custom type mapper? Any
Continue readingTests validate data spring boot with Mock
Issue My first method that I’m trying to validate, it receives an entity and gets the date to do the validation: public boolean validaDataItem(RequestPedidoDTO requestPedidoDTO) { boolean valido = true; List<Item> itemDTOS = requestPedidoDTO.getItens(); for (int i = 0; i
Continue readingSpring boot – How to Write Setter and Getter field Name Dynamic way
Issue I am getting the record last 6 months from the database. Based on the current Date. I am storing into an JSONArray when I am returning it – I am getting Serialization Error, because there is not Getter and
Continue readingSpring boot – Not a managed type
Issue I use Spring boot+JPA and having a problem while starting the service. Caused by: java.lang.IllegalArgumentException: Not an managed type: class com.nervytech.dialer.domain.PhoneSettings at org.hibernate.jpa.internal.metamodel.MetamodelImpl.managedType(MetamodelImpl.java:219) at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:68) at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getMetadata(JpaEntityInformationSupport.java:65) at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:145) at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:89) at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:69) at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:177) at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:239) at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:225)
Continue readingI have a problem with testing adding user with password encoder
Issue I have a problem when testing a method with using passwordencoder: Cannot invoke "org.springframework.security.crypto.password.PasswordEncoder.encode(java.lang.CharSequence)" because the return value of "com.store.restAPI.user.UserConfig.passwordEncoder()" is null` Thats my test class method: @ExtendWith(MockitoExtension.class) class UserServiceTest { private UserService underTest; @Mock private UserRepository userRepository; @Mock
Continue readingSleuth not able to generate traces for JDBCTemplate access
Issue I am exploring slueth for enabling tracing in our Apps. I get the API to API call logs in zipkin but I don’t get any other JDBC calls logged. I have added below to my application.yml spring: sleuth: jdbc:
Continue readingSpring Boot – combine nested resources for single API calls
Issue Suppose you have two resources, User and Account. They are stored in separate tables but have a one-to-one relationship, and all API calls should work with them both together. For example a POST request to create a User with
Continue readingSpring data repository works without annotations
Issue I’m using Spring Data JPA repositories (like MyRepo extends JpaRepository) and it works without @Repository and without @EnableJpaRepositories annotations. Could someone explain why? Solution Probably you are using Spring Boot. Spring Data repositories usually extend from the Repository or
Continue readingDocument field as primary key not working
Issue I have a "document" field that needs to be a primary key and must be unique, but every time I do a POST with the same document it updates the document and doesn’t send a BAD_REQUEST My entity: @Entity
Continue readingWhy does Spring MVC controller method ignore FetchType.LAZY behaviour and act like FetchType.EAGER?
Issue My Film model explicitly states it should fetch its children Actors lazily. @Entity @Getter @Setter public class Film { … @ManyToMany(fetch = FetchType.LAZY) @JoinTable( name = "film_actor", joinColumns = @JoinColumn(name = "film_id"), inverseJoinColumns = @JoinColumn(name = "actor_id") ) private
Continue readingRead multiple barcodes from single image file using Zxing library in java service
Issue Hi i have created a java service for reading the barcode from image here iam using Zxing library for decoding the text here the challenge is if a file with single barcode it’s working fine if there are multiple
Continue readingSpring Security Microsoft Oauth2 Login Errors
Issue I’m attempting to access Microsoft Account oauth without any Azure AD accounts, but I am receiving an unauthorized_client error before the redirect back to my app. Here is my yml configuration for spring security: spring: security: oauth2: client: registration:
Continue readingsaml2Login method cannot be resolved
Issue I followed Spring Security SAML2 Using G Suite as Idp Cannot resolve method ‘saml2login’ in ‘Http Security’ I am getting this error some body plz help. Solution Solution: I am using spring boot 2.1.x version in my project. On
Continue readinghow to do Okta SSO Integration with SpringBoot app? and all user management would be on Okta's Side
Issue I would like some help please, Trying to implement okta sso with some specifications with my app. If I want to add the ability to SSO with OKTA to an already existing Application, Without creating new users in the
Continue readingHow to implement SSO with multi back-end services and decoupled architecture
Issue BACKGROUND: There are several services (spring boot REST API services and some other productions with REST API) as back-end and some angular applications (some web site with different second-level domain name) as front-end. One front-end application can call some
Continue readingAzure Single Sign on post request giving 403 forbidden error
Issue I am working on the jsp-springboot application ,I have implemented the sso using azure and it is working as expected. I have configured azure.activedirectory.tenant-id azure.activedirectory.client-id azure.activedirectory.client-secret Also I have added the redirect url as well In the application.properties ,
Continue readingMultiple markers at this line – The type NoOpPasswordEncoder is deprecated – The method getInstance() from the type NoOpPasswordEncoder is deprecated
Issue I am working on Spring Cloud + Boot example. In this example I am looking to do SSO. When I run this application, I get the response fine, but looks like Multiple markers at this line – The type
Continue readingSpring Boot SAML using AWS SSO as IdP errors with Bad Input
Issue I want to build a site hosted with Spring Boot and I would like to use AWS SSO as the SAML identity provider for authentication. I have built a PoC application and tried to follow AWS configuration instructions and
Continue reading