Monday, December 24, 2018

Disabling Spring Security in Spring Boot

If you have a Spring boot application configured with the Spring Security, whenever you are requesting a resource/page, it will invoke the basic security and show you a login page. So how to avoid this and access your resource without any security restriction. The simple step is use security.ignored properties. Add the below


in your, you are good to go. Now accessing any restricted resource doesn't put any constraints for you.

Note: This works fine for version below Spring Boot 2.0.0. I haven't tried or exposed to Spring Boot 2.0.0.

Happy Programming...!!!

Saturday, June 2, 2018

Class has two properties of the same name exception

I think, it's because of the place where we use the "@XMLElement" annotation in the (bean) class. JAXB (annotation processor) considers the member field & getter method of the same field element as different properties, when we use the @XMLElement annotation at the field level it throws the IllegalAnnotationExceptions exception.

Below is the sample exception, which i encountered, when i placed the @XMLElement annotation on the property of my class

com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 6 counts of IllegalAnnotationExceptions
Class has two properties of the same name "accountNum"
this problem is related to the following location:
at public java.lang.String
this problem is related to the following location:
at private java.lang.String

To resolve this issue, JAXB offers a lot of flexibility when interacting with your object model. One area is configuring the use of fields or properties to access the data in your domain objects. This is specified as an XmlAccessType (PUBLIC_MEMBER, PROPERTY, FIELD, or NONE) via the @XmlAccessorType annotation. So, you add the XmlAccessType to your class, as shown below, will resolve the issue.


Happy Programming...!!!