need help w annotation spring core
package ru.alishev.springcourse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import javax.annotation.*;
/**
* @author Neil Alishev
*/
@Component
public class ClassicalMusic implements Music {
String[] arrClass = {"Hungarian Rhapsody", "Mass in B Minor", "3. Symphony No. 9 in D Minor, Op. 125"};
@PostConstruct
public void doMyInit(){
System.out.println("Doing my init");
}
@PreDestroy
public void doMyDestroy(){
System.out.println("Doing my destroy");
}
@Override
public String[] getSong() {
return arrClass;
}
}
have problem w @PostConstruct @PreDestroy
Cannot resolve symbol 'PostConstruct'
Cannot resolve symbol 'PreDestroy'3 Replies
⌛
This post has been reserved for your question.
Hey @40г белка! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
Yeah, they're a little bit annoying, you'll need the jakarta.annotation dependency.
Not that preferably you won't need these annotations at all.
If you really need to close a resource as the component shuts down, okay fine, but it's not that common.
As much as possible, PostConstruct should be replaced by doing it in the constructor, like, during construct.
Post Closed
This post has been closed by <@789513154366799924>.