Skip to content
Advertisement

Tag: spring

Tomcat and Tomcat dbcp issue after upgrade to v9.0.58

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

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

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

Advertisement