Do Spring @Component classes have to be public?
java, spring
Solution
No, components don't have to be public. The only requirement is that they have a no-arg constructor.
Problem
I'd like to expose a component's interface as an interface and the implementing class would be package protected (and maybe in some other package): ``` package baz.iface interface Foo { void bar(); } package baz.whatever @Component class SpringyFoo implements baz.iface.Foo { public void bar() { frobnicate(); } } ``` Assuming `baz.whatever` is in the `component-scan`, will Spring be able to autowire a `baz.iface.Foo` somewhere else? ``` class FooClient { @Autowired private baz.iface.Foo; } ```