We started a new project in the previous Spring. And we chose Spring framework to manage many functionality, we were so lucky to make this decision.
The Spring annotations are very calm and comfortable. We created a configuration class:
@EnableScheduling
@Configuration
@ComponentScan(basePackages = {
"org.whatever.sthg",
"org.whatever.sthg.util"
})
public class BeansConfig {
....
}
The Spring annotations are very calm and comfortable. We created a configuration class:
@EnableScheduling
@Configuration
@ComponentScan(basePackages = {
"org.whatever.sthg",
"org.whatever.sthg.util"
})
public class BeansConfig {
....
}
With the @Configuration annotation you can mark your class, it contains the configuration.
With the @EnableScheduling you can define late chron like jobs.
With the @ComponentScan you can list your packages where Spring framework could find the @Autowired, desired beans.
For example a @Controller and an autowired @Component class:
@Controller
public class CommonController {
@Autowired
private DomainFacadeInterface domainFacade;
...
}
@Component
public class DomainFacadeImpl implements DomainFacadeInterface {...}
@Autowired
private DomainFacadeInterface domainFacade;
...
}
@Component
public class DomainFacadeImpl implements DomainFacadeInterface {...}
The entry point should be an xml file, or static main() function to bootstrap Spring framework.
We decided to use the web.xml with the following extra lines:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
org.whatever.BeansConfig
</param-value>
</context-param>
You can forget to maintain massive XML files.

