Ide Spring

  • Spring Core Basics
  • Spring Questions and Answers
  • Spring Useful Resources
  • Selected Reading

With MyEclipse Spring IDE, get all the things you need for Spring framework development from built-in libraries to bean development tools, and even Spring scaffolding for jump starting your Spring projects. But, Spring is only part of the picture. MyEclipse is a multi-purpose IDE that’s well equipped for Spring development and so much more. There is already an article about this in DZone Spring IDE and the Spring Tool Suite - Using Spring in Eclipse. While the Spring IDE project provides a set of plugins for the Eclipse IDE, the Spring Tool Suite comes as a ready-to-use distribution of the latest Eclipse releases with the Spring IDE components pre-installed.

Genuitec, for its part, is offering its $199-per-year MyEclipse for Spring IDE at the end of this month. Based on a collaboration between Genuitec and Skyway Software, MyEclipse for Spring offers. AWS Cloud9 is a cloud-based integrated development environment (IDE) that lets you write, run, and debug your code with just a browser. It includes a code editor, debugger, and terminal. Cloud9 comes prepackaged with essential tools for popular programming languages, including JavaScript, Python, PHP, and more, so you don’t need to install.


So far you have seen how we configure Spring beans using XML configuration file. If you are comfortable with XML configuration, then it is really not required to learn how to proceed with Java-based configuration as you are going to achieve the same result using either of the configurations available.

Java-based configuration option enables you to write most of your Spring configuration without XML but with the help of few Java-based annotations explained in this chapter.

@Configuration & @Bean Annotations

Annotating a class with the @Configuration indicates that the class can be used by the Spring IoC container as a source of bean definitions. The @Bean annotation tells Spring that a method annotated with @Bean will return an object that should be registered as a bean in the Spring application context. The simplest possible @Configuration class would be as follows −

The above code will be equivalent to the following XML configuration −

Here, the method name is annotated with @Bean works as bean ID and it creates and returns the actual bean. Your configuration class can have a declaration for more than one @Bean. Once your configuration classes are defined, you can load and provide them to Spring container using AnnotationConfigApplicationContext as follows −

You can load various configuration classes as follows −

Example

Let us have a working Eclipse IDE in place and take the following steps to create a Spring application −

StepsDescription
1Create a project with a name SpringExample and create a package com.tutorialspoint under the src folder in the created project.
2Add required Spring libraries using Add External JARs option as explained in the Spring Hello World Example chapter.
3Because you are using Java-based annotations, so you also need to add CGLIB.jar from your Java installation directory and ASM.jar library which can be downloaded from asm.ow2.org.
4Create Java classes HelloWorldConfig, HelloWorld and MainApp under the com.tutorialspoint package.
5The final step is to create the content of all the Java files and Bean Configuration file and run the application as explained below.

Here is the content of HelloWorldConfig.java file

Here is the content of HelloWorld.java file

Following is the content of the MainApp.java file

Once you are done creating all the source files and adding the required additional libraries, let us run the application. You should note that there is no configuration file required. If everything is fine with your application, it will print the following message −

Injecting Bean Dependencies

When @Beans have dependencies on one another, expressing that the dependency is as simple as having one bean method calling another as follows −

Here, the foo bean receives a reference to bar via the constructor injection. Now let us look at another working example.

Example

Let us have a working Eclipse IDE in place and take the following steps to create a Spring application −

StepsDescription
1Create a project with a name SpringExample and create a package com.tutorialspoint under the src folder in the created project.
2Add required Spring libraries using Add External JARs option as explained in the Spring Hello World Example chapter.
3Because you are using Java-based annotations, so you also need to add CGLIB.jar from your Java installation directory and ASM.jar library which can be downloaded from asm.ow2.org.
4Create Java classes TextEditorConfig, TextEditor, SpellChecker and MainApp under the com.tutorialspoint package.
5The final step is to create the content of all the Java files and Bean Configuration file and run the application as explained below.

Here is the content of TextEditorConfig.java file

Here is the content of TextEditor.java file

Following is the content of another dependent class file SpellChecker.java

Following is the content of the MainApp.java file

Once you are done creating all the source files and adding the required additional libraries, let us run the application. You should note that there is no configuration file required. If everything is fine with your application, it will print the following message −

Eclipse Ide Spring Boot

The @Import Annotation

The @Import annotation allows for loading @Bean definitions from another configuration class. Consider a ConfigA class as follows −

You can import above Bean declaration in another Bean Declaration as follows −

Now, rather than needing to specify both ConfigA.class and ConfigB.class when instantiating the context, only ConfigB needs to be supplied as follows −

Lifecycle Callbacks

The @Bean annotation supports specifying arbitrary initialization and destruction callback methods, much like Spring XML's init-method and destroy-method attributes on the bean element −

Specifying Bean Scope

The default scope is singleton, but you can override this with the @Scope annotation as follows −

The latest version if Spring Tool Suite can be downloaded using below link,

On writing this post the latest version of Spring Tool Suite (STS) IDE is 4.9.0

Spring Boot Download

The previous versions can be downloaded in below link,

This post will guide to install Spring Tool Suite 4 IDE on windows machine.

DownloadSTS IDE

On clicking the above 4.9.0 windows 64 bit link, the spring tool suite self extracting jar will be downloaded,

spring-tool-suite-4-4.9.0.RELEASE-e4.18.0-win32.win32.x86_64.self-extracting.jar

Install STS IDE

Click the jar file and it will start to extract the files to a folder like sts-4.9.0.RELEASE.

Spring Ide Intellij

Spring

Utc 9.00. Click the SpringToolSuite4.exe to launch the Spring Tool Suite 4 Workbench

By Default workspace folder structure will be,

C:UsersDocumentsworkspace-spring-tool-suite-4-4.9.0.RELEASE

Change the default workspace folder if needed and click Launch to open the STS Workbench.

The Spring Tool Suite IDE can be used for developing Spring Boot Applications. Just click on Create new Spring Starter Project to begin with creating your first Spring Boot Application.

Instead of downloading a separate IDE for STS, Spring Tools 4 can be installed as a plugin in Eclipse. STS IDE is based on eclipse that has inbuilt features to develop Spring Based applications.