I’m getting this issue when upgrading Tomcat and Tomcat DBCP from v9.0.54 to v.9.0.58 with Java 11. Answer This issue was happening when we were trying to create a BasicDataSource BasicDataSource dataSource = new BasicDataSource(); which was imported from import org.apache.tomcat.dbcp.dbcp2.BasicDataSource; So we found a workaround to remove the tomcat dbcp dependency by excluding it from spring-boot starter tomcat and
Tag: spring
Is it possible to use thymeleaf variables to sum them in JS?
Here is the form I have ( many dishes where each has an input number ( quantity of dishes to order ). The problem is that I would like to show the price of an order before the order is done, for this I need to sum somehow input of the ${dish.price}, but how can this be done? JS (
Is there any way to inject Interceptor from external library in Spring?
I’m developing a jar library and trying to inject an interceptor from external jar library to Application. For example: External Lib MyExternalInterceptor.java I tried to using AOP in external libs but it’s not working. InterceptorAspect.java In Application using that lib: Application MyConfiguration.java Is there any way to inject an interceptor from external lib to App? I know the question is
Factory pattern using generics
I would like to build a class that caches classes of type CachedObject using Map. Below is the factory class. I have a class that extends CacheableObject as below: When I try to create an instance of class X that extends CachedObject using the get method in the factory as below: (please note that cachedObjectFactory is autowired using Spring) I
Java Spring and Existing HTML site
I have established connection between my Spring project and MySQL DB, I also have an existing HTML site with login and register templates. Can someone point me into the right direction on how to connect Spring with my existing HTML? Answer In order to implement login and register workflow you need to implement few things: REST API http endpoints for
Spring Controller GET/POST/PUT to another interface
I am using React as frontend and Java Spring Boot as backend. React sends JSON form data as GET/PUT/POST requests to my backend url (http://localhost:8080/test). Now, I wan’t to send this JSON forward to another interfaces GET endpoint (https://another/interface/add?id={id}). This interface then queries database based on the id and answers 200 OK message with a JSON reply which I need
Spring Boot and OAuth2 server
I’m trying to implement a simple OAuth2 server with Spring Boot. In the first step I added in the main class the annotation @EnableAuthorizationServer and I use the “application.yml” file to configure all the OAuth2 elements. With this configuration everything works fine. In the second step I tried to switch the configuration from yml file to java class. These are
Spring server POST method gives JSON error, Invalid UTF-8 middle byte
I have a JavaFX app and a Java server, I am trying to send a post method with a JSON but when I do I get this error from the server My post request looks like this The filmToDelete is and arraylist of Film objects. And this is mine controller methond on the server So what I would like to
How to set up init method with file constants for Spring Application?
I’m pretty new in Java Spring usage, so here’s my question. I need to inject some information into DB before my application starts. I mean, I know how to use @Bean init-method, but i dont’t want to hardcode constants even in .properties file. Here’s my temporary solution (data is changed): But this IS hardcode, what’s more, every client will have
How to test a Java/Spring service using RestTemplate without calling external API and by using Dependency Injection?
In my Spring application, i have a service MyService. MyService calls an external API, counts the products there and returns the result. To call that API it uses the Spring module RestTemplate. To inject the RestTemplate it is configured as @Bean in the DependencyConfig: Now i want to test it, without calling the external API. So i inject the MyService