Skip to content

Instantly share code, notes, and snippets.

@Bean
public PersistenceExceptionTranslationPostProcessor exceptionTranslation() {
return new PersistenceExceptionTranslationPostProcessor();
}
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Component
public @interface Repository {
/**
* The value may indicate a suggestion for a logical component name,
* to be turned into a Spring bean in case of an autodetected component.
* @return the suggested component name, if any (or empty String otherwise)
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Component
public @interface Service {
/**
* The value may indicate a suggestion for a logical component name,
* to be turned into a Spring bean in case of an autodetected component.
* @return the suggested component name, if any (or empty String otherwise)
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Indexed
public @interface Component {
/**
* The value may indicate a suggestion for a logical component name,
* to be turned into a Spring bean in case of an autodetected component.
* @return the suggested component name, if any (or empty String otherwise)
@Component
public class MyComponent {
/**
* Can able to directly mention the value inside @Value annotation
*/
@Value("Hello Sample")
private String sampleValue;
/**
* the value for the property lici.value read from the application.properties file
lici.value=Hello Sample
lici.myproperty = Hello My Property
lici.array = First,Second,Third
lici.myrank = 4
lici.underscore.values=A_B_C
lici.kevin.details={name: 'ajin', age: '23', country: 'india'}
@Lazy
@Component
public class LazyClass {
public LazyClass() {
System.out.println(">>>>>>>>>LazyClass Initialized<<<<<<<<<<<");
}
public void hello() {
System.out.println("Hello....");
@Lazy
@Component
public class LazyClass {
public LazyClass() {
System.out.println(">>>>>>>>>LazyClass Initialized<<<<<<<<<<<");
}
}
@Lazy
@Configuration
public class MyLazyConfiguration {
@Bean
public NormalClass normalClass() {
return new NormalClass();
}
@Bean
public LazyClass lazyClass() {
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.4.4)
2021-04-20 13:21:12.178 INFO 18520 --- [ main] c.lici.spring.SpringExamplesApplication : Starting SpringExamplesApplication using Java 15 on LAPTOP-13R0SDGH with PID 18520 (C:\Programming\Workspace\LearnIt_CodeIT\spring-examples\target\classes started by anish in C:\Programming\Workspace\LearnIt_CodeIT\spring-examples)
2021-04-20 13:21:12.180 INFO 18520 --- [ main] c.lici.spring.SpringExamplesApplication : No active profile set, falling back to default profiles: default