私はSpringでautowiredされているプレーンなPOJOを持ち、そのプロパティは持続しているようです。Spring Beanのプロパティが永続する
私は幸せなパスがOKであることを確認します。 - Beanのプロパティを設定して戻ります。ただし、私が幸せなパスにいなくても、プロパティ(この場合はresponseCode)を設定したくない場合は、以前の値に設定されています(コールが成功したとき)。
私はこの値を設定しないで、モデルで現在指定している値と同じにします。
私は、次のPOJOプロトタイプ豆
package com.uk.jacob.model;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@Component
@Scope("prototype")
public class Website {
public String url;
public boolean response;
public int responseCode = 0;
}
私はそれがRestController
package com.uk.jacob.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.uk.jacob.model.Website;
import com.uk.jacob.service.PingerService;
@RestController
@RequestMapping("api/v1/")
public class PingController {
@Autowired
PingerService pingerService;
@RequestMapping(value = "ping", method = RequestMethod.GET)
public Website getPing(@RequestParam String url){
return pingerService.ping(url);
}
}
'ApplicationContext#getBean(" website ")についてもっと詳しく説明できますか?それはなんですか?私のコードの問題は何ですか? –