I am trying to write a simple Java program that displays Hello World as a microservice. I am using Spring Boot, but due to security reasons at my company, I am unable to use Maven. Therefore, I have no option but to download the jar files and add them to my project. I have done so, and made sure I
Tag: spring-boot
How to add querydsl-mongodb to Spring Boot Gradle 5.6.1 project
I am trying to create dynamic query to a mongo database from spring boot gradle project. My gradle version: 5.6.1 Here is my build.gradle file: My application.properties file: Problem is: Q classes are not generating for my Documents. Any suggestion welcome. Thanks. Answer I made it working by adding both @Document and @Entity annotation. My build.gradle file is like: My
How to handle UsernameNotFoundException spring security
How to handle UsernameNotFoundException ? In spring security when username not found the UserDetailsService implementation throws a UsernameNotFoundException. For example like this: I would like to build a custom “User not found REST response”. How should I catch/handle this exception? I have implemented a handler method in the WebSecurityConfigurerAdapter implementation the handler: But this method should wait for an AuthenticationException
Java – Spring Boot: Access-Control- Allow-Origin not working
I tried to implement Access-Control- Allow-Origin in spring boot using few tutorials and this link but not able to implement this. To implement this, in application.properties file, I added below line Which probably means that except the URL https://example.com, no other endpoint can call any APIs. But it’s not working I still can see * in response , in below
Why is Log4j2 not logging inside Spring Boot Application?
I’m trying to use spring boot starter and spring boot starter web. So far I’ve got what I think is a pretty simple set up. I can see that the application is obviously finding and using the log4j2-spring.xml file so my question is why doesn’t anything from the MyRunner class log via log4j2? It does execute and the System.out.println() statements
How to use Criteria in JPA in Spring boot?
I am using JPA and spring boot. I am new to JPA. I want to retrieve an object by passing the value of the function. But in example, it is done through hibernate config. I have not config sessionFactory bean in my classpath. I want to use JPA to retrieve the object. Here in the example, it is: But I
SpringBoot 2.2.1 groovyMarkupConfigurer exception
I have a SpringBoot application that was developed with JDK8 and was now ported to JDK11. I get the following exception at startup: Here is my pom.xml: I have tried SpringWebStarter from 2.1.8 up to 2.2.1, I am always getting the same error. I cannot use JDK8 again, since the computer has been updated from Windows 7 to Windows 10
Use application.properties in a non-spring injected class
I have a class which is created with new B(this); in this class B I want to use a value from the application.properties. But because (as far as I understand) because it’s not created with Spring it won’t have any injection (I use the @Value annotation) That is how the class is created: The class in question: So my question
Setting up properly SonarQube for Code Coverage
I’m using JUnit5 on a SpringBoot backend application server using Maven. Here is the sonar-project.properties file that is at the root of the project: I use the sonar-scanner command line to run update the project after a build/test. The Overview board on sonar-cloud looks like this: I at least got the unit tests to be recognized, but somehow I’m still
Primary key values are getting updated in Spring boot
I have created a maven project using Spring Boot with MySQL database. I have two entity classes that have a primary key in one entity class and another one has a composite primary key. Customer.java(Has a primary key) ItemId.java (Idclass for Item.java) Item.java (Has a composite primary key) here the problem is when an entity object is persisted through repository