The @Value annotation is used to inject property values into variables, usually Strings or simple primitive values. You can find more info here.
If you want to load a resource file, use a ResourceLoader like:
@SpringBootApplication
public class ExampleApplication implements CommandLineRunner {
    @Autowired
    private ResourceLoader resourceLoader;
    @Autowired
    private CountWords countWords;
    public static void main(String[] args) {
        SpringApplication.run(ExampleApplication.class, args);
    }
    @Override
    public void run(String... args) throws Exception {
        System.out.println("Count words : " + countWords.getWordsCount(resourceLoader.getResource("classpath:file.txt")));
    }
}
Another solution, you can to use @Value like:
@SpringBootApplication
public class ExampleApplication implements CommandLineRunner {
    @Value("classpath:file.txt")
    private Resource res;
    @Autowired
    private CountWords countWords;
    public static void main(String[] args) {
        SpringApplication.run(ExampleApplication.class, args);
    }
    @Override
    public void run(String... args) throws Exception {
        System.out.println("Count words : " + countWords.getWordsCount(res));
    }
}