With recent versions of Spring (tested with spring 4.1) and Java Configuration and Java 8, you can use Optional in parameters, and are only autowired if available.
@Autowired
public MyApplication(Optional maybeObject) {
// do something with the optional autowired
}