Guice does not have a similar concept. For example, Guice can automatically inject any class with a default constructor without the need for any special class annotation. Why does spring have to know about every bean on startup? For the purposes of autowiring, cant spring just lookup the class from the classpath? One reason I can think of is for AOP. But if you're not using AOP, the whole bean definition computation adds a significant amount of startup time which is totally unnecessary.
EDIT:
Explicitly, I want spring to lookup a class on demand from the classpath
@Component
class Bar {
}
@Component
class Foo {
@Autowired Bar bar;
public void doSomething() {}
}
So When I create the bean Foo
by using getBean()
spring can see that it needs a Bar
so it can simply lookup Bar
on the classpath. This is what Guice does, and it avoids unnecessary component scanning which is terribly slow during development.