What def Keyword Does?
def is a replacement for a type name. In variable definitions it is used to indicate that you don’t care about the type. In variable definitions it is mandatory to either provide a type name explicitly or to use “def” in replacement. This is needed to make variable definitions detectable for the Groovy parser.You can think of def as an alias of Object and you will understand it in an instant.

def name = "Stephanie"
println name.toUpperCase() // no cast required

while you would need an explicit cast in the Java version

Object name = "Stephanie";
System.out.println(((String) name).toUpperCase());

Omitting the “def” keyword puts the variable in the bindings for the current script and groovy treats it (mostly) like a globally scoped variable:

x = 1
assert x == 1
assert this.binding.getVariable("x") == 1

Using the def keyword instead does not put the variable in the scripts bindings:

def y = 2
assert y == 2
try {
    this.binding.getVariable("y") 
} catch (groovy.lang.MissingPropertyException e) {
    println "error caught"
} 

Prints: “error caught”

If you define a method in your script, it won’t have access to the variables that are created with “def” in the body of the main script as they aren’t in scope:

x = 1
def y = 2

public bar() {
    assert x == 1

    try {
        assert y == 2
    } catch (groovy.lang.MissingPropertyException e) {
        println "error caught"
    }
}

bar()

prints “error caught”

The “y” variable isn’t in scope inside the function. “x” is in scope as groovy will check the bindings of the current script for the variable.

JARs to be added

  • poi-3.8.jar
  • poi-examples-3.8.jar
  • poi-excelant-3.8.jar
  • poi-ooxml-3.8.jar
  • poi-ooxml-schemas-3.8.jar
  • poi-scratchpad-3.8.jar
  • dom4j-1.6.1.jar

Reading Excel Sheet

import org.apache.poi.ss.usermodel.*;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.xssf.usermodel.*;
import org.apache.poi.ss.util.*;
import org.apache.poi.ss.usermodel.*;
import java.io.*;
 
class ExcelReader {
  
  def readData() {
        def path = "D:\\Test.xlsx";
        InputStream inputStream = new FileInputStream(path);
        Workbook workbook = WorkbookFactory.create(inputStream);
        Sheet sheet = workbook.getSheetAt(0);
                      
        Iterator rowIterator = sheet.rowIterator();
        rowIterator.next()
        Row row;                       
        def rowsData = []
        while(rowIterator.hasNext()) {
             row = rowIterator.next()
             def rowIndex = row.getRowNum()
             def colIndex;
             def rowData = []
             for (Cell cell : row) {
                 colIndex = cell.getColumnIndex()
                  rowData[colIndex] = cell.getRichStringCellValue().getString();
             }                    
             rowsData << rowData
         }
         rowsData
  }
 }
 
def groovyUtils = new com.eviware.soapui.support.GroovyUtils(context)
def myTestCase = context.testCase
 
ExcelReader excelReader = new ExcelReader();
List rows = excelReader.readData();
def d = []
Iterator i = rows.iterator();
while( i.hasNext()){
         d = i.next();
         myTestCase.setPropertyValue("From", d[0])
         myTestCase.setPropertyValue("To", d[1])       
         testRunner.runTestStepByName( "ConversionRate")
}

How to view Budget

  1. Growth
  2. Development
  3. Inflation(Stability in Economy)
  4. Immediate Challenges

Based on how well the above things are promised and how feasible the solutions are for the above
we can rate the budget

The motive of Government Budget is to increase GDP.It is like when the whole economy goes up the GDP goes up. When the Cake that should be shared is large everyone gets a big piece out of it.When the economy grows, GDP grows and cash flow among people would grow.

In our GDP 2 out of 3 comes from Service sector and foreign clients contribute a huge part of it.

GDP can be measured like one below

GDP = C + I + G + (x-m)

G – Government Stimulus to promote economy Growth
X – Export
I – Private Investment
C – Consumption Expenditure(Affected due to demonetization at present)
m – Imports

As per the current Situation

  • There is No Major Government Stimulus
  • Import is more then Export.So x-m is Negative
  • Private Investment is Lethargic because of Trump
  • Consumption is low because of demonetization

Government Stimulus helps in Capital Expenditure. Capital Expenditure is the One Incurred by the Company during initial stages of establishment. Capital Expenditure are very less compared to Revenue Expenditure. Revenue Expenditure helps in daily process or functioning of company like purchase of raw materials to making it finished goods.

Difference Between Deficit, Revenue, Expenditure and Relationship

SOAP REST
SOAP is a protocol. REST is an architectural style.
SOAP can’t use REST because it is a protocol. REST can use SOAP web services because it is a concept and can use any protocol like HTTP, SOAP.
Uses services interfaces to expose the business logic. Uses URI to expose business logic.
JAX-WS is the java API for SOAP web services. JAX-RS is the java API for RESTful web services.
SOAP standards should be strictly followed since it is protocol REST does not define too much standards like SOAP
requires more bandwidth and heavy requires less bandwidth and resource
SOAP defines its own security RESTful web services inherits security measures from the underlying transport.
SOAP permits XML data format only. REST permits different data format such as Plain text, HTML, XML, JSON etc.
SOAP is less preferred REST more preferred than SOAP

When to use SOAP?

  • Exposes operation over a logic – It aligns to enterprises application needs and goals
  • When using SMTP(Simple Mail Transfer Protocol) and JMS
  • It could be used when multiple systems are involved in Distributed Environment I.E. System A -> System B -> System C
  • In a complex system like banks WSDL serves as a agreed agreement for interpreting data over different system
  • SOAP uses two varieties,Synchronous Messaging over HTTP,Asynchronous Messaging over HTTP
    With synchronous messaging, the Requestor makes a request and the transport layer code blocks waiting for a response from the Provider. The Requestor receives the response on the same HTTP connection that the Requestor initially established to send the request. Synchronous exchange is usually easier to implement and requires that the Provider be able to generate a response in a short time, specifically in a time less than the HTTP timeout value(generally 120sec). [A single HTTP Connection is used that itself behaves Synchronously]
    With asynchronous messaging, the Requestor is able to release transport specific resources once the request is acknowledged by the responder, knowing that a response will eventually be received. When the Provider completes the processing of the message it sends a response back to the Requestor over a new HTTP connection. [Here we utilize two HTTP Connections to implement an asynchronous messaging]

    1. first HTTP Connection is used that for sending the Request and receiving an acknowledgement HTTP Response 200/OK
    2. second HTTP Connection is used for receiving the callback and responding HTTP Response 200/OK]
  • SOAP has a option for Service Registry where you can see who is registered for services and who could consume our services
  • Ideal for enterprise application where security(WS-Security), transaction(WS-AT) and reliability(WS-RM) are main concerns

When to use REST?

  • Exposes Resources over data – Simple point to pint communication between two systems System A -> System B
  • While working with synchronous environment
  • Could be used if you want to communicate over Stateless protocol like HTTP/HTTPS
  • It could be consumed by any Client simple by using AJAX and Javascript
  • Rest mostly uses resource as nouns and verbs like delete user, add user, edit user in its URI model
  • REST is purely an HTTP transport based call and you will receive a response say 200 OK. Synchronous messaging. The disadvantage is in order to
    have good scale-ability the architecture should be asynchronous
  • Ideal for mashup where datas are taken from various resources like twitter and less secured data communication

Puzzle 1:Crossing the Bridge Puzzle
Four people need to cross a rickety bridge at night. Unfortunately, they have only one torch and the bridge is too dangerous to cross without one. The bridge is only strong enough to support two people at a time. Not all people take the same time to cross the bridge. Times for each person: 1 min, 2 mins, 7 mins and 10 mins. What is the shortest time needed for all four of them to cross the bridge?

Puzzle 2:Burning Rope Timer:
A man has two ropes of varying thickness (Those two ropes are not identical, they aren’t the same density nor the same length nor the same width). Each rope burns in 60 minutes. He actually wants to measure 45 mins. How can he measure 45 mins using only these two ropes.
He can’t cut the one rope in half because the ropes are non-homogeneous and he can’t be sure how long it will burn.

Puzzle 3:How do you measure 50 Mins in the above scenario?

Puzzle 4:Heaven Gate Puzzle:
You are standing before two doors. One of the path leads to heaven and the other one leads to hell. There are two guardians, one by each door. You know one of them always tells the truth and the other always lies, but you don’t know who is the honest one and who is the liar.You can only ask one question to one of them in order to find the way to heaven. What is the question?

Puzzle 5:King and Wine Bottles
A bad king has a cellar of 1000 bottles of delightful and very expensive wine. A neighboring queen plots to kill the bad king and sends a servant to poison the wine. Fortunately (or say unfortunately) the bad king’s guards catch the servant after he has only poisoned one bottle. Alas, the guards don’t know which bottle but know that the poison is so strong that even if diluted 100,000 times it would still kill the king. Furthermore, it takes one month to have an effect. The bad king decides he will get some of the prisoners in his vast dungeons to drink the wine. Being a clever bad king he knows he needs to murder no more than 10 prisoners – believing he can fob off such a low death rate – and will still be able to drink the rest of the wine (999 bottles) at his anniversary party in 5 weeks time. Explain what is in mind of the king, how will he be able to do so ? (of course he has less then 1000 prisoners in his prisons)

Puzzle 6:Age Puzzles
Salman’s youth lasted one sixth of his life. He grew a beard after one twelfth more. After one seventh more of his life, he married. 5 years later, he and his wife had a son. The son lived exactly one half as long as his father, and salman died four years after his son.How many years did salman live?

Puzzle 7:Inverted Triangle Puzzle
Triangle is constructed from 10 coins. What is the smallest number of coins that need to be moved to make the triangle point downwards?

Puzzle 8:Birds and Flower Puzzle
Once there came many birds to a pond. There were certain number of lotus flowers in the pond. If each bird occupied one lotus one bird was left alone without any flower. If two birds sat in a flower one flower was left behind. Find the total number of birds and flowers.

Puzzle 9:Time and Machines
If it takes 5 machines 5 minutes to make 5 widgets, how long would it take 100 machines to make 100 widgets?

Puzzle 10:Fastest of 25 Horse
There are 25 horses among which you need to find out the fastest 3 horses. You can conduct race among at most 5 to find out their relative speed. At no point you can find out the actual speed of the horse in a race. Find out how many races are required to get the top 3 horses.

Puzzle 11:A bat and a ball cost $1.10 in total. The bat costs $1.00 more than the ball. How much does the ball cost?
The Question is tricky in the sense the cost of bat is never unveiled.What is said is how much the bat would cost in excess with respect to ball price.If you are witty you end up telling ball cost is 0.10 which is wrong for below reason.

Puzzle 12: Find age of Daughters
Rishi has three daughters. His friend Shyam wants to know the ages of his daughters. Rishi gives him the first hint.
1.The product of their ages is 36.Shyam says this is not enough information so rishi gives him a second hint.
2.The sum of their ages is equal to my house number. Shyam goes out and look at the house number but still could not figure out ages of daughter
rishi tells Shyam cannot guess and gives him the third hint. 3.The oldest of the girls likes ice-cream.

Puzzle 13: There are 10 robbers who has stolen some coins from a bank and they decided to divide these coins equally among themselves. So they divide the coins into 10 parts but the last robber got 1 coin less than other robbers. So the remaining 9 robbers murder las robber. They again decided to divide the coins into 9 parts. But this time again the last robber got 1 less coin than other robbers. So again the remaining 8 robbers murder last and try to divide all coins in between remaining 8 robbers. But again this time last got one less coin than the other. Now, this process goes on until 1 robber left i.e. The only one robber left take all the coins and run away. Now you have to guess the total number of coins.

Puzzle 14: You have 10 Coins in which 5 are heads up and 5 are tails up. You could not find the which coin is head up and tails up by touching. Now you need to make 2 piles with both the piles having same no of coins heads up and tails up.


Solutions

Puzzle 1:Solution
It is 17 mins.1 and 2 go first, then 1 comes back. Then 7 and 10 go and 2 comes back. Then 1 and 2 go again, it makes a total of 17 minutes.

Puzzle 2:Solution
He will burn one of the rope at both the ends and the second rope at one end. After half an hour, the first one burns completely and at this point of time, he will burn the other end of the second rope so now it will take 15 mins more to completely burn. so total time is 30+15 i.e. 45mins.

Step 1: Burn one rope in both the ends and one rope in one end
Rope 1  x------------------------------------------x       
Rope 2  x------------------------------------------        

After 30 Mins rope 1 would be completely burnt and rope 2 would be left as below
Rope 1  ...................x........................
Rope 2  ...................x------------------------        

Step 2: After 30 Mins lid the other end of rope to measure 15 mins
Rope 1  ...................x........................
Rope 2  ...................x-----------------------x        

After 45 Mins
Rope 1  ...................x........................
Rope 2  ...........................................x          

x    Fire
---- Rope
.... Burnt Rope Ash

Puzzle 3:Solution
50mins can be split to 30 Mins1/2 of an hour + 20 Mins1/3 of the hour which is buring one rope from both ends + burning rope in one end and in middle of rope. We already know to measure 30 mins the rope should be lid on both the ends. To measure 20 mins the rope should be lid in 2 places as below. The second spot can be anywhere in the middle of the rope. Since the rope burns non uniformly it doesn’t matter. Now this should be done again and again until the rope burns out. Basically, we are measuring 1/3rd of hour by burning at 2 ends.

Rope 2  x--------x----------------------------------        After nth minute
Rope 2                     x--------------x---------        After n+1 minute
Rope 2                          x----x                      After n+2 minute

Puzzle 4:Solution
“If I ask the other guard about which side leads to heaven, what would he answer?”.

Puzzle 5:Solution
Think in terms of binary numbers.

Number the bottles 1 to 1000 and write the number in binary format (10 digit binary).

bottle 1    = 0000000001 
bottle 2    = 0000000010
bottle 500  = 0111110100
bottle 1000 = 1111101000

Now take 10 prisoners and number them 1 to 10, now let prisoner 1 take a sip from every bottle that has a 1 in its least significant bit. Let prisoner 10 take a sip from every bottle with a 1 in its most significant bit. etc.

prisoner = 10 9 8 7 6 5 4 3 2 1
bottle 924 = 1 1 1 0 0 1 1 1 0 0

For instance, bottle no. 924 would be sipped by 10,9,8,5,4 and 3. That way if bottle no. 924 was the poisoned one, only those prisoners would die.
After four weeks, line the prisoners up in their bit order and read each living prisoner as a 0 bit and each dead prisoner as a 1 bit. The number that you get is the bottle of wine that was poisoned.1000 is less than 1024 (2^10). If there were 1024 or more bottles of wine it would take more than 10 prisoners.

Puzzle 6:Solution

x/6 + x/12 + x/7 + 5 + x/2 + 4 = x

where x is salman’s age at the time of his death.Therefore, salman lived exactly 84 years.

Puzzle 7:Solution

Puzzle 8:Solution
There are 4 lotus flowers and 3 birds. Let the 0s represent the birds. Let the 1s represent the lotus flowers.
CASE 1:Each bird sat on each lotus flower, one bird was left alone.

                          1      1      1       1
                          0      0      0      

CASE 2:Two birds sat on each lotus flower, one flower was left alone.

            
                       (1 1)       (1 1)
                          0           0            0

Another Way of Solving
Let F be the flowers and B be the Birds. If Birds and Flower are equal in Number then F=B. Below the Equations are Derived from Birds Perspective.
As per Case1 B = F+1 (If one bird is sitting in one flower then one more flower is required)
As per Case2 B/2 = F-1 (If 2 birds occupy flower then one flower is extra)

From Case1 F = B/2+1 Replacing the value of F in Case1

B = B/2+1+1
2B=B+4;
B(Birds)=4;

Replacing B=4 in Case1
F(Flowers)=3;

Puzzle 9:Solution
5 Minutes

Puzzle 10:Solution

  1. Step1:Split the horses into five sets and race among them.At the end of Five race you could identify the fastest horse in the set
  2. Step2:Now race the top 5 horses from 5 set and get the fastest of all horse.It is 41 in our case
  3. Step3:Reorder the set in such a way that Fastest horse set comes first ending up with slowest horse.
  4. Step4:Now we can remove the remaining horses from last 2 groups as we know for sure that horses in those group cannot be second and third fastest horse since there are horses faster than the horses in 4 and 5th from the 6th race we conducted
  5. Step5:Now I could remove the remaining horses in third set since I know they could not be 3rd fastest as we know the fastest horse in group
  6. Step6:Lets remove the other 3 horses in second group as I know 3rd fastest horse is in third group(Race2)
  7. Step7:I am going to eliminate the last 2 horses in first group(Race3) since we are interested in first 3 fastest horse
  8. Step8: Lets have a final race 7 to find the fastest three horse from set of {24,21,26,36,20,30} which is {36,30}
Step1
Race1	10	36	11	20	15	
Race2	15	18	19	10	30	
Race3	21	24	10	41	10	
Race4	11	10	19	4	13	
Race5	25	17	6	9	19	
						
						
Race1	36	20	15	11	10	
Race2	30	19	18	15	10	
Race3	41	24	21	10	10	
Race4	19	13	11	10	4	
Race5	25	19	17	9	6	

Step2 and Step3						 
Race3	41	24	21	10	10	
Race1	36	20	15	11	10	
Race2	30	19	18	15	10	
Race5	25	19	17	9	6	
Race4	19	13	11	10	4	
		
Step4				
Race3	41	24	21	10	10	
Race1	36	20	15	11	10	
Race2	30	19	18	15	10	

Step5						
Race3	41	24	21	10	10	
Race1	36	20	15	11	10	
Race2	30					

Step6						
Race3	41	24	21	10	10	
Race1	36	20				
Race2	30					

Step7						
Race3	41	24	21			
Race1	36	20				
Race2	30					

Step8
Race3	41	
Race1	36	
Race2	30					

						
Fastest Horse  1	41					
Fastest Horse  2	36					
Fastest Horse  3	30				

Refer here

Puzzle 11:Solution

x = ball 
y = bat

x + y = 1.10;
y = x + 1; 
x + x + 1 = 1.10;
2x + 1 =1.10;
2x = 0.10;
x=0.5;

Cost of ball = 0.5;
Cost of bat =  1.05;

Puzzle 12:Solution
Shyam is able to guess after the third hint. Can you guess what are the ages of three daughters?

Hint 1: The product of their ages is 36

1 × 1 × 36 = 36
1 × 2 × 18 = 36
1 × 3 × 12 = 36
1 × 4 × 9 = 36
1 × 6 × 6 = 36
2 × 2 × 9 = 36
2 × 3 × 6 = 36
3 × 3 × 4 = 36

Hint 2: The sum of their ages is equal to my house number

1 + 1 + 36 = 38
1 + 2 + 18 = 21
1 + 3 + 12 = 16
1 + 4 + 9 = 14
1 + 6 + 6 = 13
2 + 2 + 9 = 13
2 + 3 + 6 = 11
3 + 3 + 4 = 10

Here in is the crux of the puzzle, we obviously don’t know the man’s door number. We can assume that the second man does. At this stage we are only assuming, but the fact that he is able later, to definitively answer the puzzle will mean that this is no longer an assumption. And remember we are trying to explain what happened. Even with the door number, the second man does not know the ages of the daughters, so it must still be ambiguous, there are only two combinations that have the same total which leads to ambiguity.

1 + 6 + 6 = 13
2 + 2 + 9 = 13

Hint 3:The oldest of the girls likes ice-cream
Since there is only one oldest the combination is 2 + 2 + 9 = 13.The daughters age is 2,2,9.

If the above question is asked with third hint youngest daughter has blue eyes then the answer would be 1 + 6 + 6 = 13.The daughters age is 1,6,6

Puzzle 13:Solution
Let the robbers be

  Robber1,Robber2,Robber3,Robber4,Robber5,Robber6,Robber7,Robber8,Robber9,Robber10

  After Split1
  Robber1,Robber2,Robber3,Robber4,Robber5,Robber6,Robber7,Robber8,Robber9

  After Split2
  Robber1,Robber2,Robber3,Robber4,Robber5,Robber6,Robber7,Robber8

  After Split3
  Robber1,Robber2,Robber3,Robber4,Robber5,Robber6,Robber7

  .
  .

  After Split10
  Robber1

Let the total coins be N.After the first split Robber10 gets 1 coin less than remaining so they kill Robber10. So in order for equal split it should be (N+1) Coins in total.The same thing happens again and again. Let’s substitute robbers with numbers for ease of split.

Robber1	  -	1
Robber2	  -	2
Robber3	  -	3
Robber4	  -	4
Robber5	  -	5
Robber6	  -	6
Robber7	  -	7
Robber8	  -	8
Robber9	  -	9
Robber10  -	10

If the coins needs to be equally split, we need to arrive at a number which is divisible by all the robbers. We need to find Least Common Multiple for above number

Total Coins for equal split = LCM(10,9,8,7,6,5,4,3,2,1) = 2520

Since we have one coin less that LCM of above number the total coins robbers took is 2519.

Puzzle 14:Solution
Make 2 piles with the equal number of coins. Now, flip all the coins in one of the pile.

Case 1:

P1 : H T T T T
P2 : H H H H T

After flipping

P1 : T H H H H
P2 : H H H H T

P1(heads) = P2(heads)

Case 1:

P1 : H T H T T
P2 : H H T H T

After flipping

P1 : T H T H H
P2 : H H H H T

P1(heads) = P2(heads)

What is difference between Eclipse Project -> Clean and mvn clean?

Eclipse project clean is only clearing out the folders that are set as output folder in the project’s preferences.It Deletes previously generated Eclipse files (like .project and .classpath and .settings) and then generates new ones, thus, effectively updating them.

It may be useful if you introduced some changes in pom.xml

mvn clean command deletes target directory and then builds all you code and
installs artifacts into local repository.

What Maven update Project Does?

It syncs the Eclipse project settings with that of the pom. If you for example change important plugin settings, such as the output java version, you will find that Eclipse will ask you to update the project and afterwards the configured Java runtime in the project will have changed to reflect what your Maven pom indicates.

  1. That is an important thing to keep in mind: the Maven pom is the lead in this kind of project setup. If you want settings to change, try to do that through the pom and not through Eclipse project settings directly or doing a project update might revert what you have changed. There are usually some things I have to correct myself anyway though, such as build path exclusions that m2eclipse likes to put in and strange deployment assembly configurations.
  2. Update Project also provides more options such as Force Update of Snapshots / Releases which is extremely helpful when you have dependencies that are looking for the latest. (e.g.: [1.0) will find 1.0.* – whatever’s the latest.)

Two types of Maven dependencies
Direct: These are dependencies defined in your pom.xml file under the section.
Transitive: These are dependencies that are dependencies of your direct dependencies.

What are dependencies with provided scope meant to?
Either be excluded from the final artifact (for example, for war files you would not want to include servlet-api, servlet-jsp, etc) since the server itself has the servlet related jar files

Difference Between Update Snapshots and Update Dependency
By default Maven is supposed to update snapshots once a day.Specific dependency is determined using group, name and version. These attributes can be identical for two different snapshots. Maven uses the latest snapshot based on internal time stamp.

what is the difference between classpath and build path?
The classpath is the conventional way to tell the Java compiler and the Java runtime where to find compiled classes.The class path is used at runtime to load compiled classes and resources.

The build path is used for building your application. It contains all of your source files and all Java libraries that are required to compile the application.The IDE uses this to figure out the classpath and sourcepath for compiling the Java code.The build path is used at compile time to find the dependencies needed to build your project.

For example, an Eclipse build path for a project includes the other projects that it depends on, and lists any additional library JARs that the project contains / relies on. It also lists the packages in the current project that downstream projects can depend on.

If you are using Maven for your project, the IDE buildpath mechanism is secondary to the dependencies declared in the POM files. For example, using Eclipse with the m2eclipse, the buildpath is synthesized from the POM files.

What is .project and .classpath files in Eclipse
The .project file is maintained by the core Eclipse platform, and its goal is to describe the project from a generic, plugin-independent Eclipse view.When a project is created in the workspace, a project description file is automatically generated that describes the project. The sole purpose of this file is to make the project self-describing, so that a project that is zipped up or released to a server can be correctly recreated in another workspace.

.classpath Classpath specifies which Java source files and resource files in a project are considered by the Java builder and specifies how to find types outside of the project. The Java builder compiles the Java source files into the output folder and also copies the resources into it.

what mvn eclipse:eclipse does
Sometimes the dependencies don’t update even with Maven->Update Project->Force Update option checked using m2eclipse plugin.

mvn eclipse:eclipse

This will update your .classpath file with the new dependencies while preserving your .project settings and other eclipse config files.

If you want to clear your old settings use


mvn eclipse:clean
mvn eclipse:eclipse

mvn eclipse:clean will erase your old settings, then mvn eclipse:eclipse will create new .project, .classpath and other eclipse config files

What is Maven artifact?
An artifact is a file, usually a JAR, that gets deployed to a Maven repository.

Maven is based around the central concept of a build lifecycle.
There are three built-in build lifecycles

There are three lifecycle phases in maven

  1. clean
  2. build (default)
  3. site

You can Either trigger a phase or goal in maven

When the clean lifecycle is called it has three phases internally.For example, the clean life cycle has 3 phases (pre-clean, clean, post-clean).

For example the default lifecycle comprises of the following Build Phases:

◾validate – validate the project is correct and all necessary information is available
◾compile – compile the source code of the project
◾test – test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed
◾package – take the compiled code and package it in its distributable format, such as a JAR.
◾integration-test – process and deploy the package if necessary into an environment where integration tests can be run
◾verify – run any checks to verify the package is valid and meets quality criteria
◾install – install the package into the local repository, for use as a dependency in other projects locally
◾deploy – done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.

So to go through the above phases, we just have to call one command:

>> mvn

i.e

>> mvn install

For the above command, starting from the first phase, all the phases are executed sequentially till the ‘install’ phase. A command can be used in a multi-module scenario mvn clean install.

A Build Phase is Made Up of Plugin Goals
Most of Maven’s functionality is in plugins. A plugin provides a set of goals that can be executed using the following syntax:

mvn [plugin-name]:[goal-name]

For example, a Java project can be compiled with the compiler-plugin’s compile-goal by running mvn compiler:compile

Build lifecycle is a list of named phases that can be used to give order to goal execution.

Goals provided by plugins can be associated with different phases of the lifecycle

mvn test

When the preceding command is executed, Maven runs all goals associated with each of the phases up to and including the test phase. In such a case, Maven runs the resources:resources goal associated with the process-resources phase, then compiler:compile, and so on until it finally runs the surefire:test goal.

A goal not bound to any build phase could be executed outside of the build lifecycle by direct invocation. The order of execution depends on the order in which the goal(s) and the build phase(s) are invoked. For example, consider the command below. The clean and package arguments are build phases, while the dependency:copy-dependencies is a goal (of a plugin).

mvn clean dependency:copy-dependencies package

If this were to be executed, the clean phase will be executed first (meaning it will run all preceding phases of the clean lifecycle, plus the clean phase itself), and then the dependency:copy-dependencies goal, before finally executing the package phase (and all its preceding build phases of the default lifecycle).

Furthermore, a build phase can also have zero or more goals bound to it. If a build phase has no goals bound to it, that build phase will not execute. But if it has one or more goals bound to it, it will execute all those goals.

The image showing various plugins goals used for different phase during execution.To take the other way round plugins executing goals at different phases.

Maven is a “build management framework”

You could define how your .java files get compiled to .class, packaged into .jar (or .war or .ear) files, (pre/post)processed with tools, managing your CLASSPATH, and all others sorts of tasks that are required to build your project.

 Though it doesn’t give fine grain control like  Apache Ant or Gradle or Makefiles in C/C++, but it attempts to be completely self-contained in it that you shouldn’t need any additional tools or scripts by incorporating other common tasks like downloading & installing necessary libraries etc.

It is also designed to around “build portability” so that you don’t get issues as having the same code with the same buildscript working on one computer but not on another one (this is a known issue, we have VMs of Windows 98 machines since we couldn’t get some of our Delphi applications compiling anywhere else). Because of this, it is also the best way to work on a project between people who use different IDEs since IDE-generated Ant scripts are hard to import into other IDEs, but all IDEs nowadays understand and support Maven.

There are few inflexibility in maven and some developers stick with Ant or similar, but a growing number of them are people who have moved on to Maven successors such as Gradle and Buildr. These successors inherit from Maven the idea of providing a powerful set of build steps out of the box, but make it immensely easier to add custom steps too.

​How to apologise if you are late to meeting

Instead of offering up a reason or excuse for why you were late, focus your apology on the impact you’ve made or the problems you’ve caused. Say something like “Sorry for keeping you waiting” or “I’m so sorry for taking up more of your time” or even “Thank you for your flexibility.” If you show everyone that you’re sorry for using up their valuable time, your apology will sound much more sincere.

Spring vs EJB

App servers written to support the EJB standard can, in theory, be ported from one compliant Java EE app server to another. But that means staying away from any and all vendor-specific extensions that lock you in to one vendor.

Spring ports easily between app servers (e.g., WebLogic, Tomcat, JBOSS, etc.) because it doesn’t depend on them

Spring Boot offers an even better way to write applications without Java EE app servers. You can create an executable JAR and run it on a JVM.

The Spring framework sits on top of the application servers and service libraries. Service integration code (e.g. data access templates) resides in the framework and is exposed to the application developers. In contrast, the EJB 3 framework is integrated into the application server and the service integration code is encapsulated behind an interface. EJB 3 vendors can thus optimize the performance and developer experience by working at the application server level. For example, they can tie the JPA engine closely to JTA transaction management. Another example is clustering support which is transparent to EJB 3 developers

Spring vs J2EE

Strictly speaking, Spring is a framework while Java EE is a specification which is implemented by various softwares such as JBoss and Glassfish.
The greatest difference is that Spring is an actual library while JavaEE is an API that has to be implemented. Depending on the JAVA EE container you could find a full implementation (e.g. Glassfish), a partial implementation (e.g. Tomcat) a full implementation with extra sugar (e.g. JBoss and others).