+01 (414) 230 - 5550
JAVA, Technology

Spring Initializer – using Java and Maven

Spring Initializr is a web tool which is provided by Spring on official site https://start.spring.io/ We can create Spring Boot project by providing project details.

 

In the below example, we added the springboot-starter-web dependency to write REST Endpoints.

 

spring_initializer_img

 

After providing the Group, Artifact, Dependencies, Build Project, Platform and Version, click Generate Project button. The zip file will get downloaded and the files will be extracted. After the project is downloaded, unzip the file.

 

The maven file pom.xml will have the Web dependency we had selected above.

 

Web_dependency_img

 

Note that only the Spring boot starter parent has a version number. Spring boot starter web doesn’t have a version as it is automatically configured based on version of the parent.

 

You can find the main class file under src/java/main directories with the default package.

 

directories_img

 

To write a simple Hello World Rest Endpoint in the Spring Boot Application main class file itself, follow the steps shown below:

 

  • Firstly, add the @RestController annotation at the top of the class.
  • Now, write a Request URI method with @RequestMapping annotation.
  • Then, the Request URI method should return the Hello World string.

 

application_main_img

 

Create an executable JAR by executing the below Maven command in the folder having pom.xml C:\Users\SaravananP\Downloads\demo\mvn clean install

 

install_img

 

The .jar file will be created in the target folder as indicated above

 

Run the Jar file using java –jar and verify the results

 

verify_img

 

result_img

 

Application Properties

In the above examples, we have seen that Spring boot automatically configured Tomcat to run in port 8080. We can override this by specifying the port in the file src\main\resources\application.properties

 

port_img

 

If we rebuild the jar and execute it, we will get an error in http://localhost:8080 and be able to see the Hello World message in http://localhost:9090

 

404_img

 

result_img1
0

JAVA, Technology

Spring Boot

Spring Boot is an open source Java-based framework used to create Micro Services. It is used to build stand-alone and production ready spring applications.

 

What is Micro Service?

Micro Service is an architecture that allows the developers to develop and deploy services independently. Each service running has its own process, and this achieves the lightweight model to support business applications.

 

Features and benefits of Spring Boot

  • Spring boot provides a flexible way to configure Java Beans, XML configurations, and Database Transactions.
  • It provides a powerful batch processing and manages REST endpoints.
  • In Spring Boot, everything is auto configured; no manual configurations are needed.
  • It offers annotation-based spring application.
  • Eases dependency management.
  • It includes Embedded Servlet Container.
  • It is highly dependent on the starter templates feature.

 

How Spring Boot works

Spring Boot automatically configures our application based on the dependencies we have added to the project by using @EnableAutoConfiguration annotation. For example, if MySQL database is on our classpath, but we have not configured any database connection, then Spring Boot auto-configures an in-memory database.

 

Spring Boot Starters

Handling dependency management is a difficult task for big projects. Spring Boot resolves this problem by providing a set of dependencies for developer’s convenience.

 

For example, if we want to create a web application with REST Endpoints, it is sufficient if we include spring-boot-starter-web dependency in our project.

 

Note that all Spring Boot starters follow the same naming pattern spring-boot-starter-*, where * indicates that it is a type of the application.

 

Example:

 

Spring Boot Starter Test dependency is used for writing Test cases. Its code is shown below:

 

 

Spring Boot Application

The entry point of the Spring Boot Application is the class containing @SpringBootApplication annotation. This class should have the main method to run the Spring Boot application. @SpringBootApplication annotation includes @EnableAutoConfiguration, @ComponentScan, and @SpringBootConfiguration annotations.

 

Spring Boot automatically scans all the components included in the project by using @ComponentScan annotation.

 

Observe the following code for a better understanding:

 

 

Spring Boot – Quick Start – using Groovy

The Spring Boot CLI is a command line tool and it allows us to run the Groovy scripts. Create a simple groovy file which contains the Rest Endpoint script.

 

Hello.groovy

 

 

The above file can be run using the command “spring run Hello.groovy”

 

spring_command_img

 

Once we run the groovy file, required dependencies will download automatically and it will start the application in Tomcat 8080 port as shown in the screenshot above. You can also see that sping ‘Mapped “{[/]}” onto public java.lang.String Example.hello()’.

 

We can go to the web browser and hit the URL http://localhost:8080/, and see the output from hello() function as shown below:

 

hello_spring_img

 

Click here to continue >>

0

Azure, Cloud

1. Security and Compliance:

If you are wondering why we are starting with security, then check out this number. $6 trillion, that’s the amount of annual damage cyber crimes is predicted to cost us by 2021.

 

Which is precisely why the first thing you need to check while picking your cloud service provider is their security and compliance levels – both physical as well as virtual – this includes the geographical location of their data centers and the local laws of the country they are based in.

 

There are a number of certifications and standards which guarantee the security preparedness of cloud vendors; their validity must be checked and additional investigations must be carried out by checking internal and third-party audits or reports.

 

You need to do a deep check of:

  • Security infrastructure and procedures followed by the vendor
  • Identity management and authorizations
  • Physical security controls including the process for natural disasters
  • Policies for data back-up and disaster recovery

 

2. Technical Capabilities

An obvious point, but it still needs to be reiterated.

 

Your service provider should have a full stack of technologies that support your current applications and also has the capability to match your future needs.

 

Cloud partnerships last a long time, and it’s important to check the future roadmap of the service provider to understand if they have the mindset to catch trends early and innovate.

 

Some questions to focus on:

  • Will your current software and applications integrate easily with the service provider’s cloud infrastructure?
  • Do they use standard interfaces and APIs for easy integration?
  • Do they have the capability of providing hybrid cloud computing options and do they have the flexibility to host different cloud environments and systems?
  • Are they backing their capabilities with SLAs?
  • Are they willing and capable to architect solutions tailored to your business?

 

3. Costs

No two cloud service providers have similar or comparable pricing packages. They each have their own formula of computing cloud costs, and it is almost impossible to make a side-by-side comparison of different vendors. What you need to do is map out your organization’s requirement as minutely as possible and then decide which pricing model suits your needs.

 

Keep in mind:

  • Consumption timelines as long-term contracts are better priced
  • The flexibility offered by service providers in scaling up or down
  • Check for hidden costs

 

4. Business Health

The stability of your business depends on the stability of its partners, and you cannot underestimate the importance of a cloud partner. Before finalizing your cloud vendor, it is important to check their business and financial health.

 

You should check:

  • The company’s financial records
  • Management structure and other third-party relationships
  • Reputation, reviews, and referrals from existing customers
  • For any legal run-ins
  • All available third-party audits

 

5. Support

Do you just have a phone or chat access or does your service provider offers dedicated account management? How much support you can get from your vendor is another important criteria, that must be considered before finalizing a service provider.

 

Find out about:

  • Time guarantees for solving technical issues
  • Access to support services – 24×7 or 12×5
  • Cost of opting for dedicated resources

 

Deciding on a cloud service provider is a long process that demands complete thoroughness and analysis from the CIO and the rest of the team.

 

Before we leave you to navigate your way to your future cloud partner, here are two more important points that must be considered – Right size and exit strategy.

 

Keep in mind that to get the best service you need to find a vendor who connects with you and for whom you are a valuable client.

And always plan an exit strategy in case things don’t work out.

 

Best of Luck!

0