Skip to content

Instantly share code, notes, and snippets.

@arwagner
Last active December 27, 2015 04:48
Show Gist options
  • Save arwagner/7268989 to your computer and use it in GitHub Desktop.
Save arwagner/7268989 to your computer and use it in GitHub Desktop.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'foobarService' defined in file [/Users/wagnera/workspace/j+hs/onboard/onboardservices/target/classes/com/agilex/onboardservices/services/FoobarService.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.BeanInitializationException: Property 'text' is required for bean 'foobarService'
@Service
public class FoobarService {
private static final Logger logger = LoggerFactory.getLogger(FoobarService.class);
private String text;
public void report() {
logger.info("text: " + getText());
}
public String getText() {
return text;
}
@Required
public void setText(String text) {
logger.info("setText called");
this.text = text;
}
}
@Controller
public class HomeController {
@Autowired
private FoobarService foobarService;
@RequestMapping(value = "/", method = RequestMethod.GET)
public String home(Locale locale, Model model) {
foobarService.report();
return "home";
}
}
root-context.xml:
...
<bean id="foobarService" class="com.agilex.onboardservices.services.FoobarService">
<property name="text" value="foobar"/>
</bean>
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment