Submitted by jjadmin on Sat, 05/14/2016 - 21:14
We can use the property 'spring.profiles.active' within a properties file to activate a profile and is the most preferred approach.
In last note, we had seen enabling Spring profiles from the main method itself by calling getEnvironment().setActiveProfiles method on the AnnotationConfigApplicationContext object.
Submitted by heartin on Sat, 05/14/2016 - 13:13
@Profile annotation allow you to register components that will be selected only if its associated profile is active. You can selectively activate a set of beans in a class or all beans .
We will see how to do this using a Java configuration file using the @Profile annotation, and then we will also discuss about how to do it using XML configuration.
Important points about Spring Profiles
Submitted by heartin on Sat, 05/14/2016 - 09:07
We will create a simple class, configure it and test it. You can configure a Spring application through xml, or Java configuration or annotations along with xml or java configuration. In this example we will use @Component and @ComponentScan annotations along with Java configuration. Note that these annotations can also be used along with xml configuration and we will see how to do that in the end.
Submitted by heartin on Sat, 05/14/2016 - 04:37
We will create a simple class, configure it and test it. You can configure a Spring application through xml, or Java configuration or annotations along with xml or java configuration. In this example, we will see java configuration approach. We will have a Java class annotated with @Configuration to hold bean configuration.
Submitted by heartin on Fri, 05/13/2016 - 20:31
Please follow the below guidelines for answering questions.
Answer within the question bank itself, without changing the name.
Color your answers with blue color.
Color your execution results in yellow color. Sometimes you might be asked to first answer without trying out and then actually try compiling/executing it. This step is not mandatory.
Submitted by jjadmin on Sun, 05/01/2016 - 01:31
Write a program that accept two directories (or even two drives or hard disks), efficiently compare them and tell the files/locations which are not same. It should also tell if a file has been changed based on factors such as size, timestamp etc.
Basically it needs to act as a file system backup tool that suggests the files that need to updated to the backup device or vice versa. However, it may not actually copy the files or do the backup.
Submitted by heartin on Sat, 04/30/2016 - 22:32
This is a quick summary of important keywords and reserved words that you should not be using as an identifier. Identifier is a name given to any class, method, interface, enum or variable that we create. There is also added quick notes section with few important keywords that may be useful for exam or interview preparations.
Keywords in Java
class, interface, enum(added in 5.0), package, import, new, this, super, return, void.
Submitted by heartin on Sat, 04/30/2016 - 21:55
Based on the scope in which the variable is declared, we can classify variables as Class variables, Instance Variables and Local variables.
Class variables (or static variables)
Class variables (or static variables) are declared within a class and outside all methods using the static keyword.
Example: Static variable
static int myVar;
Submitted by jjadmin on Fri, 04/22/2016 - 06:45
@Autowired, @Resource, and @Inject are examples for annotations that are used for dependency injection in Spring.
While @Autowired is provided by the Spring framework, @Resource and @Inject are java standard annotations.
When using annotation-based dependency injection, if the dependency is not injected, we would get an exception at the startup of our application itself.
Submitted by jjadmin on Sun, 04/17/2016 - 06:31