Manually Install Java and Maven

Download Java from the following Link

http://www.oracle.com/technetwork/java/javase/downloads/index.html

Download Maven from the following Link

https://maven.apache.org/download.cgi

Then unzip the files to java and maven folders. For Ubuntu, it is better to install /usr/apps/

then create a symlink to the latest version inside the folder using following commands

Go into the java folder (/usr/apps/java)

ln -s ./UNZIPPED_JAVA_VERSION current

After creating the symbolic link you will have (/usr/apps/java/current)

Go into the maven folder (/usr/apps/maven)

ln -s ./UNZIPPED_MAVEN_VERSION current

After creating the link similarly you will have (/usr/apps/maven/current)

When you create a symlink for the latest version as current you only have to download the next latest version and change the symbolic link only. Otherwise, you have to change all the configured locations. This will reduce a hazard.

Then apply the following configurations to the ~/.bash_profile

#Java home and Java Path
JAVA_HOME=/usr/apps/java/current
M2_HOME=/usr/apps/maven/current

PATH=$JAVA_HOME/bin:$M2_HOME/bin:$PATH:$HOME/.local/bin:$HOME/bin

export JAVA_HOME
export M2_HOME
export PATH

Save the .bash_profile

Next the path variable should be updated by running the .bash_profile. For that run the following command

source ~/.bash_profile

Attaching a new Disk in AWS

mount the disk at os level if you created a new disk

use following commands

format and create a disk of type :  /dev/xvdf

sudo mkfs -t ext4 /dev/xvdf

then

mount it, /u01 is the mount point

sudo mount /dev/xvdf /u01

open the following file as the root user

/etc/fstab

add the following line to the end of the file

/dev/xvdf /u01 ext4 defaults 0 0

 

http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-using-volumes.html#using-ebs-volume-linux

Spring Configuration Beans

Spring configuration

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.0.RELEASE</version>
    <relativePath/>
    <!-- lookup parent from repository -->
</parent>

 

The following example is the sample class

@Configuration
@PropertySource("classpath:application.properties")
@ConfigurationProperties(prefix = "file")
public class FileStorageProperties {
   private String authMethod;
}

@PropertySource

The application.property which resides in the classpath will be read to identify the configuration properties for the above property.

@Configuration

This property will be identified as an autowire candidate.

@ConfigurationProperties

This will remark the configuration property and prefix will identify the appropriate properties for the class.

 

Following any form will assign the above authMethod variable.

file.auth_method
file.auth-method
file_AUTH_METHOD
file_AUTH_METHOD

 

Now let’s say we have a hierarchy of properties as follows.

#Object properties
mail.credentials.username=nuran
mail.credentials.password=password
mail.credentials.authMethod=SHA1
The following configuration class can be organized as follows to retrieve the above configurations.
public class ConfigProperties {


    public static class Credentials {
        private String authMethod;
        private String username;
        private String password;


       // standard getters and setters

    }

    private String host;

 

The following type of configuration will map the properties into the list and map.

#List properties
mail.defaultRecipients[0]=admin@mail.com
mail.defaultRecipients[1]=owner@mail.com

#Map Properties
mail.additionalHeaders.redelivery=true
mail.additionalHeaders.secure=true

 

We can also use validation properties to ensure the properties meets the requirement.

The following are some samples for validation properties.

String empty check

@NotBlank
private String host;

String length check

@Length(max = 4, min = 1)
private String authMethod;

Min-max value check for the integer

 

@Min(1025)
@Max(65536)
private int port;