Sonar: Make the enclosing method static or remove this set

450 views Asked by At

I was trying to access the non static method from class A to a static method in class B

@Component
public class B{
private static A aA1;
@Autowired
private A tA;

@PostConstruct
public void init(){
//<<<Make the enclosed method Static or remove this set>>>
B.aA1=tA;
}

public static void random method(){
aA1.doStuff();
}
}

Is it okay to make the init method static, as the sonar suggest Or is there another way i could solve this?

0

There are 0 answers