What is the use of Java access modifiers?


1. Problem description

When writing a unit test, the service class is automatically injected, but when calling the method in the service, the method written by yourself cannot be accessed.

2. Causes of problems

as a result ofMethod does not use an access modifier, add the “public” modifier to the method to access it

3. Conclusion

You can access this method in other classes by specifying the access permission of the method in the class