@Value in Springboot returns null

前端 未结 5 940
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-18 00:22

I have the application.properties, which is located in the resources

apllication.properties

hsm.provider=software
hsm.name=TestHsm
h         


        
5条回答
  •  北海茫月
    2021-01-18 00:55

    I had the same issue before and @Value was not working for controller but working for component classes so i had used below solution.

    You can @Autowire Environment environment and then environment.getProperty("hsm.provider").

    Note: This is just a workaround solution.

提交回复
热议问题