Skip to main content

Posts

Showing posts from July, 2020

Settings.xml for Maven, JFrog

For development and deployment of applications we always use an artifactory in real-time world to host artifacts needed for your build and also as a target to deploy artifacts generated in the build process. For Maven, to communicate with artifactory we need a settings.xml file which is usually located at "/User/rake/.m2/settings.xml" this file consists of how to authenticate to the artifactory servers and authorizations to read/ write to different locations like release, snapshots e.t.c... Settings.xml can be generated using the artifactory you're using which in my case is JFrog , but here's a sample settings file for your reference incase you're feeling lazy☺ <?xml version="1.0" encoding="UTF-8"?> <settings xsi:schemaLocation= "http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns= "http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi= "http://www.w3.org/2001/XM...

Find classes that use certain annotation - Java, Spring

Code to read classes that use a certain annotation: import org.springframework.beans.factory.config.BeanDefinition ; import org.springframework.context.ApplicationContext ; import org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider ; import org.springframework.core.type.filter.AnnotationTypeFilter ; ClassPathScanningCandidateComponentProvider classPathScanningCandidateComponentProvider = new ClassPathScanningCandidateComponentProvider ( false ); classPathScanningCandidateComponentProvider . addIncludeFilter ( new AnnotationTypeFilter ( CustomAnnotation . class )); Set < BeanDefinition > beanDefinitions = classPathScanningCandidateComponentProvider . findCandidateComponents ( "com.rake.demo.beans" ); for ( BeanDefinition beanDefinition: beanDefinitions ) { System . out . println ( beanDefinition . getBeanClassName ()); } Annotation: import java.lang.annotation.ElementType ; import java.lang.annotation.Reten...