Understanding Spring Boot @Autowired

I don’t understand how spring boot’s annotation @Autowired correctly works. Here is a simple example: @SpringBootApplication public class App { @Autowired public Starter starter; public static void main(String[] args) { SpringApplication.run(App.class, args); } public App() { System.out.println(“init App”); //starter.init(); } } — @Repository public class Starter { public Starter() {System.out.println(“init Starter”);} public void init() { … Read more

How can I read all users using keycloak and spring?

I’m using keycloak 3.4 and spring boot to develop a web app. I’m using the Active Directory as User Federation to retrieve all users information. But to use those information inside my web app I think I have to save them inside the “local-webapp” database. So after the users are logged, how can I save … Read more

Spring Boot YAML configuration with URL in key no longer loads correctly with version 2

I’m migrating my application from Spring Boot 1.5 to 2.0 and one of the YAML properties no longer loads correctly. The following configuration snippet: myapp serviceUrls: ‘https://example.org/test’: ‘https://test.example.org/Endpoint’ is mapped to this configuration class: @ConfigurationProperties(prefix = “myapp”, ignoreUnknownFields = false) public final class MyAppProperties { private Map<String, String> serviceUrls = new HashMap<>(); //[…] } With … Read more

Spring Boot exception: Could not open ServletContext resource [/WEB-INF/dispatcherServlet-servlet.xml]

I have developed this proof of concept https://github.com/DISID/disid-proofs/tree/master/spring-boot-weblogic to test the deployment of Spring Boot applications in Weblogic 12c (12.2.1). The application deploys and starts successfully, but when I try to connect to it (i.e. /accounts?number=1234) the error below is shown: Error 500–Internal Server Error From RFC 2068 Hypertext Transfer Protocol — HTTP/1.1: 10.5.1 500 … Read more

Spring Boot binding and validation error handling in REST controller

When I have the following model with JSR-303 (validation framework) annotations: public enum Gender { MALE, FEMALE } public class Profile { private Gender gender; @NotNull private String name; … } and the following JSON data: { “gender”:”INVALID_INPUT” } In my REST controller, I want to handle both the binding errors (invalid enum value for … Read more

SpringBoot logging – extraneous hyphen at start of every log entry

I am trying to eliminate a leading hyphen from our console and file logs in SpringBoot 1.3.5.RELEASE with default logback config. Logging pattern looks like: logging: pattern: console: ‘%d{yyyy-MM-dd HH:mm:ss.SSS} %clr([${spring.application.name}]){red} %clr(%5p) %clr(${PID:- }){magenta} %clr(—){faint} %X{req.requestId} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%rEx}’ The file log pattern is similar, without the color coding. Both output every line after … Read more

Authentication issue with repo accessed from Spring Cloud Config Server hosted on GitHub

I’m hosting a configuration in a repo on GitHub. If I keep the repo public all’s good, but if I make it private I face: org.eclipse.jgit.errors.TransportException: https://github.com/my-user/my-repo: Authentication is required but no CredentialsProvider has been registered the property I use to target the repo is spring.cloud.config.server.git.uri=https://github.com/my-user/my-repo What should I do to configure this properly with … Read more

Spring Boot + Thymeleaf ERROR java.lang.ClassNotFoundException: org.thymeleaf.dom.Attribute

I have the following problem using Spring Boot and thymeleaf and I can not fix it. The error occurs when I run the Application class, right after the error occurs. My layout with thymeleaf lies main\resources\templates HomeController @Controller public class HomeController { @GetMapping(“/”) public String root() { return “page/home”; } } Application @SpringBootApplication public class … Read more

java.lang.IllegalStateException: Failed to read Class-Path attribute from manifest of jar file spring-plugin-core-1.2.0.RELEASE.jar

I am using STS 3.9 version with using to create starter spring boot project ->Web,jpa,mysql,rest combination.This is When i try to run the spring boot application is shows error ….I tried to change the spring plugin JAR verion to 1.1.0 but still not got changes,i tried to make different projects that also produces the same … Read more

NoSuchMethodError: org.springframework.data.repository.config.RepositoryConfigurationSource.getAttribute

I am trying to use spring-data-redis in a spring-boot application to work with redis. I am creating JedisConnectionFactory as follows: RedisStandaloneConfiguration configuration = new RedisStandaloneConfiguration(); configuration.setHostName(“localhost”); configuration.setPort(6379); JedisConnectionFactory connectionFactory = new JedisConnectionFactory(configuration); It throws the exception: Exception in thread “main” java.lang.NoSuchMethodError: org.springframework.data.repository.config.RepositoryConfigurationSource.getAttribute(Ljava/lang/String;)Ljava/util/Optional; at org.springframework.data.redis.repository.configuration.RedisRepositoryConfigurationExtension.registerBeansForRoot(RedisRepositoryConfigurationExtension.java:88) at org.springframework.data.repository.config.RepositoryConfigurationDelegate.registerRepositoriesIn(RepositoryConfigurationDelegate.java:118) at org.springframework.boot.autoconfigure.data.AbstractRepositoryConfigurationSourceSupport.registerBeanDefinitions(AbstractRepositoryConfigurationSourceSupport.java:59) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java:352) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:143) at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:116) at … Read more