Closed
Description
Having a class like:
@RestController
public class MyController {
@Value("#{T(com.example.demo.TestBean1).foostatic()}")
private String something;
@GetMapping("/greeting")
public String sayHello() {
<*>
return "Hello Greeting";
}
}
When you select a bean with the name something
from the list of bean proposals, the result looks like this:
@RestController
public class MyController {
private final FeignClientExample something;
@Value("#{T(com.example.demo.TestBean1).foostatic()}")
private final String something;
MyController(FeignClientExample something) {
this.something = something;
}
MyController(FeignClientExample something) {
this.something = something;
}
@GetMapping("/greeting")
public String sayHello() {
something
return "Hello Greeting";
}
}
From my observation, this causes:
- two fields with the same name
- two constructors with the exact same content
I think the best way to deal with this situation is to - of course - avoid the duplicated constructor - and to allow the user to easily switch to a different name for the injected bean. This could be done by popping up a dialog that asks the user for a different name or to activate a multi-part edit as part of the completion that pre-selects all the occurrences of the bean name (constructor param + field), so that the user can continue typing a different name and then continue.