Skip to content

Instantly share code, notes, and snippets.

@NoUsername
Created October 10, 2017 14:30
Show Gist options
  • Save NoUsername/9e4f50892d89ebb781fb8200c7db7390 to your computer and use it in GitHub Desktop.
Save NoUsername/9e4f50892d89ebb781fb8200c7db7390 to your computer and use it in GitHub Desktop.
// AI.java
public interface AI
{
String getName();
}
// A.java
@Service
public class A implements AI
{
@Override
public String getName()
{
return "a";
}
}
// AO.java
@Service
public class AO implements AI
{
final String name;
public AOne(String name)
{
this.name = name;
}
public AOne()
{
this("DEFAULT");
}
@Override
public String getName()
{
return name;
}
}
// B.java
@Service
public class B
{
@Autowired
private AI a;
@PostConstruct
public void init()
{
System.out.println("a is: " + a.getName());
}
}
// you will always get "a is: a" although it should be a duplicate bean definition error
// tested with Spring v1.4.2.RELEASE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment