I already try to search through stackoverflow, and I don't think I find the solution I want...
Also I try to use answer https://stackoverflow.com/questions/45970442/spring-boot-value-returning-null
and still doesn't work...
Here is my controller class
package com.vincent.springoauth.controller;
import com.vincent.springoauth.model.GiftCardRequest;
import com.vincent.springoauth.model.GiftCardResponse;
import com.vincent.springoauth.service.InCommGiftCardServiceImpl;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/api/gift-card")
public class GiftCardController{
@PostMapping("/activate")
public @ResponseBody
GiftCardResponse activate(GiftCardRequest request) {
GiftCardServiceImpl giftCardService = new GiftCardServiceImpl("");
return giftCardService.activate(request);
}
}
And here is my service class
package com.vincent.springoauth.service;
import com.vincent.springoauth.model.GiftCardRequest;
import com.vincent.springoauth.model.GiftCardResponse;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@Service
@Log4j2
public class GiftCardServiceImpl {
private final String baseEndpoint;
public GiftCardServiceImpl( @Value("${webserviceurl}")String baseEndpoint){
this.baseEndpoint = baseEndpoint;
}
public String accessToken() {
log.info("Access oauth token url address: " + baseEndpoint);
// will be use that base endpoint to manipulate stuff later
return "abcdefg";
}
public GiftCardResponse activate(GiftCardRequest request) {
log.info("Calling token ...");
accessToken();
log.info("Incomm Pre Auth Service");
// Generate preAuth request;
//RetailTransactionGenericRequestWrapper retailTransactionGenericRequest = buildRequest(request);
//log.info("RetailTransactionGenericRequest: " + retailTransactionGenericRequest);
GiftCardResponse response = GiftCardResponse.builder().responseCode("0").responseMessage("Success").build();
return response;
}
}
And in my application.properties
I have following line webserviceurl=https://localhost/giftcard
The issue that in my service class the webserviceurl
return null
. How can I fix this?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…