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'
No description
3 Replies
JavaBot
JavaBot5mo ago
This post has been reserved for your question.
Hey @40г белка! Please use /close or the Close 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.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Kyo-chan
Kyo-chan5mo ago
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.
JavaBot
JavaBot5mo ago
Post Closed
This post has been closed by <@789513154366799924>.
Want results from more Discord servers?
Add your server