public interface UserService {
void addUser(User user);
}
@Service
public class UserServiceImpl implements UserService {
@Override
public void addUser(User user) {
}
}
@Controller
public class UserController {
@Autowired
private UserService userService;
}
@Configuration
@ComponentScan(basePackages = "com.example")
public class AppConfig {
}
public class Application {
public static void main(String[] args) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
UserController controller = context.getBean(UserController.class);
context.close();
}
}