Authentication “Who are you?” & Authorization “What can you do?” can be managed using Spring Security. Here we will see a simple example of using Spring Security to authenticate and/or authorize a user to access Spring MVC controller.
First step to use Spring in your Java application, is to create Spring configuration metadata, this metadata tells Spring what beans “Java classes” you need to be instantiated in Spring container. You have three options to write or code your configuration metadata “XML, annotation or Java configuration”
How to prepare Spring configuration metadata using XML, annotation or Java based configuration?
Spring framework provides a good way to write “Event-Driven” application! Using Spring we can code our own “custom event” or extends standard ones.
It would be nice to have annotations for events!
- How to develop Spring custom event, how to publish it and how to listen to it?
This is a short post on how to use MyBatis to insert an object using XML <insert> or annotation @Insert and return the value of the primary id.
The complete code on GitHub is using Spring & H2 embedded database to provide ready to run example.
- How to use <insert..> & @Insert to insert an object?
- How to get primary Id of the inserted object?
We can enable the environment-aware feature “Profile” in Spring XML configuration, also we can enable this feature using annotation @Profile in Spring @Configuration class “the Spring annotation configuration” which is equivalent to XML configuration <beans…>…..</beans>.
- How to use @Profile to load Spring configuration for specific environment?
If you like to load environment specific spring configuration you can do this using profile. In other words, if you want to load a set of beans that have different settings on different environment (development, testing or production) you can use profile feature instead of pointing to a different spring xml configuration at each stage.
- How to use profile in spring xml configuration?
We have seen in Mybatis + Spring (XML | Annotation) Mapper how to write a simple mybatis-spring app and what is actually needed to get it up and running. Here I will extend that sample code to cover more stuff that you may face in a real “coding”. We will see how to make a single select that will fetch the one and the many of a “one-to-many” relationship, who to use mybatis config file with spring (if you need it), how to test mybatis-spring code using junit and things you need to watch out!
H2 embedded database has been used to make this example easy to run. But you still can use it with other databases e.g. “MySql, Oracle,….”
- How to use make a single select that will fetch all one to many records?
- How to reference mybatis config file in spring xml config file?
- How to test using junit?
This is a simple introduction to Spring Data Neo4j which provides simpler & Spring style development model.
- How to convert POJO to Neo4j entities?
- How to interact with Neo4j db using (Neo4jTemplate)?
The easiest way to return an object as JSON without using view resolver is to add @ResponseBody before return type.
- How to build a REST service using Spring MVC to return json without using view resolver?
Using myBatis with Spring framework. (XML configuration and mapping).
- How to use myBatis with Spring framework?
- How to write mybatis config and mapper in xml?