odules:ty:compileJavaWARNING

modules:ty:compileJava WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by worker.org.gradle.internal.reflect.JavaMethod (file:/Users/---/.gradle/caches/3.0/workerMain/gradle-worker.jar) to method java.lang.ClassLoader.getPackages() WARNING: Please consider reporting this to the maintainers of worker.org.gradle.internal.reflect.JavaMethod WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release

The difference between () and ()

Spring allows you to do two things:
  1. Autowiring of beans
  2. Autodiscovery of beans
1. Autowiring
Usually in applicationContext.xml you define beans and other beans are wired using constructor or setter methods. You can wire beans using XML or annotations. In case you use annotations, you need to activate annotations and you have to add <context:annotation-config /> inapplicationContext.xml. This will simplify the structure of the tag from applicationContext.xml, because you will not have to manually wire beans (constructor or setter). You can use @Autowire annotation and the beans will be wired by type.
A step forward for escaping the manual XML configuration is
2. Autodiscovery
Autodiscovery is simplifying the XML one step further, in the sense that you don't even need too add the <bean> tag in applicationContext.xml. You just mark the specific beans with one of the following annotation and Spring will automatically wire the marked beans and their dependencies into the Spring container. The annotations are as follow: @Controller@Service@Component@Repository. By using <context:component-scan> and pointing the base package, Spring will auto-discover and wire the components into Spring container.

As a conclusion:

  • <context:annotation-config /> is used in order to be able to use @Autowired annotation
  • <context:component-scan /> is used to determine the search of specific beans and attempt of autowiring.



<context:annotation-config /> :
Enables you to use annotations that are restricted to wiring up properties and constructors only of beans!.
<context:component-scan/>:
Enables everything that <context:annotation-config /> can do, with addition of using stereotypes  @Component@Service , @Repository. So you can wire entire beans and not just restricted to constructors or properties!.

<context:annotation-config/> <!-- activates the annotations --> 
<context:component-scan base-package="" /> <!-- activates the annotations + register the beans by looking inside the base-package -->

Commentaires

Posts les plus consultés de ce blog

Failed to execute goal org.codehaus.mojo:exec-maven-plugin

java.io.IOException: Cannot run program "C:\wamp\bin\mysql\mysql5.6.17\bin": CreateProcess error=5, Access is denied