Spring ClassPathResource - cannot be opened because it does not exist

后端 未结 1 552
广开言路
广开言路 2021-01-27 04:19

UPDATE: I\'ll still keep Artem Bilan\'s answer marked as correct, but I still felt I needed to point this out for any future readers. It seems I was misundersta

相关标签:
1条回答
  • 2021-01-27 04:34

    You show src -> main -> etc., but that doesn't matter for runtime.

    If you really are going to have that file in the final application (jar? war?), be sure that you pack that file really as a part of the final application.

    And share that structure here.

    With Spring Java & Annotation Configuration you don't need to worry about ClassPathResource object. There is just enough to declare it like this in the appropriate @Configuration:

    @Value("com/my/package/name/privateKey.txt")
    private Resource privateKey;
    
    0 讨论(0)
提交回复
热议问题