Working a Getting Started guide with STS

This guide walks you through using Spring Tool Suite (STS) to build one of the Getting Started guides.

What you’ll build

You’ll pick a Spring guide and import it into Spring Tool Suite. Then you can read the guide, work on the code, and run the project.

What you’ll need

About 15 minutes

Spring Tool Suite (STS)

JDK 8 or later

Installing STS

If you don’t have STS installed yet, visit the link up above. From there, you can download a copy for your platform. To install it simply unpack the downloaded archive.

When you’re done, go ahead and launch STS.

Importing a Getting Started guide

With STS up and running, open the Import Spring Getting Started Content wizard from the File menu.

Import Getting Started Content

A pop-up wizard will offer you the chance to search and pick any of the published guides from the Spring website. You can either skim the list, or enter search words to instantly filter the options.]

The criteria is applied to both the title and the description when offering instant search results. Wildcards are supported.

You can pick either Maven or Gradle as the build system to use.

You can also decide whether to grab the initial code set, complete code set, or both. For most projects, the initial code set is an empty project, making it possible for you to copy-and-paste your way through a guide. The complete code set is all the code from the guide already entered. If you grab both, you can compare your work against the guide’s and see the differences.

Finally, you can have STS open a browser tab to the guide on the website. This will let you work through a guide without having to leave STS.

For the purpose of this guide, enter rest into the instant search box. Then pick Consuming Rest . Pick Maven for building, and initial and complete code sets. Also opt to open the web page as shown below:

Pick a guide

STS will create two new projects in your workspace, import the Consuming Rest code base (both initial and complete), and open a browser tab inside STS as shown below:

View the code and the guide

From here, you can walk through the guide and navigate to the code files.

Congratulations! You have setup Spring Tool Suite, imported the Consuming Rest getting started guide, and opened a browser tab to walk through it.

The following guides may also be helpful:

Working a Getting Started guide with IntelliJ IDEA

Want to write a new guide or contribute to an existing one? Check out our contribution guidelines .

All guides are released with an ASLv2 license for the code, and an for the writing.

Get the Code

A Guide to Spring in Eclipse STS

Last updated: January 16, 2024

sts package presentation

Spring 5 added support for reactive programming with the Spring WebFlux module, which has been improved upon ever since. Get started with the Reactor project basics and reactive programming in Spring Boot:

>> Download the E-book

Baeldung Pro comes with both absolutely No-Ads as well as finally with Dark Mode , for a clean learning experience:

>> Explore a clean Baeldung

Once the early-adopter seats are all used, the price will go up and stay at $33/year.

Azure Container Apps is a fully managed serverless container service that enables you to build and deploy modern, cloud-native Java applications and microservices at scale. It offers a simplified developer experience while providing the flexibility and portability of containers.

Of course, Azure Container Apps has really solid support for our ecosystem, from a number of build options, managed Java components, native metrics, dynamic logger, and quite a bit more.

To learn more about Java features on Azure Container Apps, visit the documentation page .

You can also ask questions and leave feedback on the Azure Container Apps GitHub page .

Java applications have a notoriously slow startup and a long warmup time. The CRaC (Coordinated Restore at Checkpoint) project from OpenJDK can help improve these issues by creating a checkpoint with an application's peak performance and restoring an instance of the JVM to that point.

To take full advantage of this feature, BellSoft provides containers that are highly optimized for Java applications. These package Alpaquita Linux (a full-featured OS optimized for Java and cloud environment) and Liberica JDK (an open-source Java runtime based on OpenJDK).

These ready-to-use images allow us to easily integrate CRaC in a Spring Boot application:

Improve Java application performance with CRaC support

Modern software architecture is often broken. Slow delivery leads to missed opportunities, innovation is stalled due to architectural complexities, and engineering resources are exceedingly expensive.

Orkes is the leading workflow orchestration platform built to enable teams to transform the way they develop, connect, and deploy applications, microservices, AI agents, and more.

With Orkes Conductor managed through Orkes Cloud, developers can focus on building mission critical applications without worrying about infrastructure maintenance to meet goals and, simply put, taking new products live faster and reducing total cost of ownership.

Try a 14-Day Free Trial of Orkes Conductor today.

To learn more about Java features on Azure Container Apps, you can get started over on the documentation page .

And, you can also ask questions and leave feedback on the Azure Container Apps GitHub page .

Whether you're just starting out or have years of experience, Spring Boot is obviously a great choice for building a web application.

Jmix builds on this highly powerful and mature Boot stack, allowing devs to build and deliver full-stack web applications without having to code the frontend. Quite flexibly as well, from simple web GUI CRUD applications to complex enterprise solutions.

Concretely, The Jmix Platform includes a framework built on top of Spring Boot, JPA, and Vaadin , and comes with Jmix Studio, an IntelliJ IDEA plugin equipped with a suite of developer productivity tools.

The platform comes with interconnected out-of-the-box add-ons for report generation, BPM, maps, instant web app generation from a DB, and quite a bit more:

>> Become an efficient full-stack developer with Jmix

DbSchema is a super-flexible database designer, which can take you from designing the DB with your team all the way to safely deploying the schema .

The way it does all of that is by using a design model , a database-independent image of the schema, which can be shared in a team using GIT and compared or deployed on to any database.

And, of course, it can be heavily visual, allowing you to interact with the database using diagrams, visually compose queries, explore the data, generate random data, import data or build HTML5 database reports.

>> Take a look at DBSchema

Get non-trivial analysis (and trivial, too!) suggested right inside your IDE or Git platform so you can code smart, create more value, and stay confident when you push.

Get CodiumAI for free and become part of a community of over 280,000 developers who are already experiencing improved and quicker coding.

Write code that works the way you meant it to:

>> CodiumAI. Meaningful Code Tests for Busy Devs

The AI Assistant to boost Boost your productivity writing unit tests - Machinet AI .

AI is all the rage these days, but for very good reason. The highly practical coding companion, you'll get the power of AI-assisted coding and automated unit test generation . Machinet's Unit Test AI Agent utilizes your own project context to create meaningful unit tests that intelligently aligns with the behavior of the code. And, the AI Chat crafts code and fixes errors with ease, like a helpful sidekick.

Simplify Your Coding Journey with Machinet AI :

>> Install Machinet AI in your IntelliJ

Since its introduction in Java 8, the Stream API has become a staple of Java development. The basic operations like iterating, filtering, mapping sequences of elements are deceptively simple to use.

But these can also be overused and fall into some common pitfalls.

To get a better understanding on how Streams work and how to combine them with other language features, check out our guide to Java Streams:

Download the E-book

Do JSON right with Jackson

Get the most out of the Apache HTTP Client

Get Started with Apache Maven:

Working on getting your persistence layer right with Spring?

Explore the eBook

Building a REST API with Spring?

Get started with Spring and Spring Boot, through the Learn Spring course:

Explore Spring Boot 3 and Spring 6 in-depth through building a full REST API with the framework:

>> The New “REST With Spring Boot”

Get started with Spring and Spring Boot, through the reference Learn Spring course:

>> LEARN SPRING

Yes, Spring Security can be complex, from the more advanced functionality within the Core to the deep OAuth support in the framework.

I built the security material as two full courses - Core and OAuth , to get practical with these more complex scenarios. We explore when and how to use each feature and code through it on the backing project .

You can explore the course here:

>> Learn Spring Security

1. Overview

This article illustrates some of the useful features of the Eclipse Spring Tool Suite (STS) IDE, which are useful when developing Spring applications .

First we show the benefits of using STS as compared to the traditional way of building applications with Eclipse.

Thereafter, we focus on how to bootstrap an application, how to run it and how to add additional dependencies. Finally we conclude by adding application arguments.

2. STS Main Features

STS is an Eclipse-based development environment that is customized for the development of Spring applications.

It provides a ready-to-use environment to implement, debug, run and deploy your applications. It also includes integration for Pivotal tc Server, Pivotal Cloud Foundry, Git, Maven and AspectJ. STS is built as an addition on top of the latest Eclipse releases.

2.1. Project Configuration

STS understands almost all of the most common Java project structures. It parses configuration files and then displays detailed information about beans that are defined, dependencies, used namespaces and in addition extracts overviews for certain stereotypes.

spring-bean-snapshot

2.2. STS Features Overview

Eclipse STS validates your project and provides quick fixes for your applications. For example, when working with Spring Data JPA, the IDE may be used to validate query method names (more on this in section 6).

STS also provides a graphical view on all bean methods and their mutual relationships. You may want to have a closer look at the graphical editors that come with STS by looking into the views that are available under the menus window , show view and then Spring respectively.

STS also offers other additional useful features that are not limited to Spring applications only. The reader is recommended to a look at the full list of features that can be found here .

3. Creation of a Spring Application

Let us start by bootstrapping a simple application. Without STS a Spring application is usually created by using the Spring Initializer website or the Spring Boot CLI . This may be simplified by clicking on Create Spring Starter Project from your dashboard in STS.

In the New Spring Starter Project screen either use the defaults or make your own adjustments and then go to next screen. Select Web and click finish. Your pom.xml should now look similar to this:

Your version of Spring Boot may be different but the latest version may always be found here .

4. Running the Application

The aforementioned application may be started by right-clicking on the project and selecting run as Spring Boot App . Without STS, you will most likely run the application from the command line with the following command:

By default, Spring applications are started with Tomcat running on port 8080. At this point, the application starts on port 8080 and basically does nothing else as we have not implemented any code yet. Section 8 shows you how to change the default port.

5. Logging and ANSI Console

When you run the project from the IDE using the run command, you will notice that the console outputs some nice color-coded log statements. In case you want to turn it off, go to run configurations … and disable the check box Enable ANSI console output on the Spring Boot tab. Alternatively, you can also disable it by setting a properties value in the application.properties file.

More information on the configuration of your application logs may be found here .

6. JPA Query Name Checks

At times implementing a data access layer may be a cumbersome activity. A lot of boilerplate code may have to be written to realize simple queries and perform pagination. Spring Data JPA (JPA) aims to significantly facilitate such an implementation of data access layers. This section illustrates some of the benefits of using JPA in conjunction with STS.

To get started, add the following dependency for JPA to the previously generated pom.xml :

You may have noticed that version has not been specified in the above declaration. This is due to the fact that dependencies are managed by the spring-boot-starter-parent .

To make JPA work, it is required that you properly define your entity managers and transaction managers. However, Spring auto-configures these for you. The only thing left to the developer is to create the actual entity classes. These entities are managed by the entity manager, which in turn is created by the container. Let us for example create an entity class Foo like so:

The container scans all classes annotated with @Entity from the root of the configuration package. Next we create a JPA repository for the Foo entity:

At this point you may have noticed already that the IDE now flags this query method with an exception:

This is of course due to the fact that we have accidentally written an ‘s’ in the method name of the JPA repository. To fix this remove the spurious ‘s’ like so:

Notice that no @EnableJpaRepositories was used on the config class. This is because the container’s AutoConfigration pre-registers one for the project.

7. Jar Type Search

“Jar Type Search” is a feature that was introduced in STS 3.5.0 . It provides content-assisted proposals in projects for classes that are not (yet) on the classpath. STS may help you adding dependencies to your POM file in case they are not yet on the classpath.

For example, let us add a line to the Foo entity class. For this example to work properly, please ensure first that the import statement for java.util.List is already present. Now we may add Google Guava as follows:

The IDE will suggest several dependencies to be added to the classpath. Add the dependency from com.google.common.collect, press return and add the dependency from Guava . The Guava jar will now automatically be added to your pom.xml file like so:

As of version STS 3.8.0 , you get a confirmation dialog box before STS makes its changes to your pom.xml.

8. Adding Application Arguments

One of the other powerful features of Spring is the support of external configurations which can be passed to an application in several ways, e.g. as command-line arguments, specified in properties or YAML files or as system properties. In this section, we focus on adding a configuration option as application start argument using STS. This is illustrated by configuring Tomcat to start on a different port.

In order to run an application on a Tomcat port other than the default, you may use the command below, where a custom port is specified as command-line argument:

When using STS, you have go to the run menu. Select run configurations … from the Run Configurations dialog, select Spring Boot App from the left panel and select demo – DemoApplication (this will be different if you did not select the default project). From (x)= Arguments tab type in the Program Arguments window

and run . You should see output in your console similar to the output that is shown below:

9. Conclusion

In this article we have shown the basics of developing a Spring project in STS. Some of the things we have shown are execution of applications in STS, support during the development of Spring Data JPA and the usage of command-line arguments. However, there are many more useful features that may be employed during development as STS offers a rich set of features.

The full implementation of this article can be found in the github project – this is an Eclipse based project, so it should be easy to import and run as it is.

Explore the secure, reliable, and high-performance Test Execution Cloud built for scale. Right in your IDE:

Basically, write code that works the way you meant it to.

AI is all the rage these days, but for very good reason. The highly practical coding companion, you'll get the power of AI-assisted coding and automated unit test generation . Machinet's Unit Test AI Agent utilizes your own project context to create meaningful unit tests that intelligently aligns with the behavior of the code.

Get started with Spring Boot and with core Spring, through the Learn Spring course:

>> CHECK OUT THE COURSE

RWS Course Banner

Follow the Spring Category

sts package presentation

  • Advance Java Course
  • Java Tutorial
  • Java Spring
  • Spring Interview Questions
  • Java SpringBoot
  • Spring Boot Interview Questions
  • Spring MVC Interview Questions
  • Java Hibernate
  • Hibernate Interview Questions
  • Advance Java Projects
  • Java Interview Questions

Creating Spring Boot Project Using STS

Spring Boot is one of the favorite items of Spring Framework, as it requires very minimal configuration, unlike Spring MVC. Spring Boot applications are easily configurable and have several other benefits to use for developing stand-alone Java applications. Spring Boot comes with,

  • Embedded Tomcat
  • ‘ Starter ‘ dependency for easy configuration
  • Automatically configures other third-party libraries.
  • Provides production features
  • No need for XML configuration

Spring Tool Suite

Spring tool suite is an eclipse-based IDE built to develop Spring-framework applications.

Spring Tool Suite

Creating Spring Boot Project

If you haven’t installed the Spring tool suite, you can check here , how to install sts in your system.

Step 1: Once sts is ready in your system, click on the executable ( .exe ) file and it will open a prompt to select project location.

Creating a Workspace in STS

Step 2: You can leave this directory as it is or can change it accordingly. Click on OK and the Spring tool suite’s home screen will open.

Workspace view

Step 3: On the left side, click on file -> new -> spring starter project.

Directory Structure

Step 4: A new window will open now, asking details for about your project

Maven bootstrap window

Description for each options shown in the above image is as follows-

  • Let the service URL be the same as start.spring.io .
  • Name your project anything you want to.
  • Choose the type as maven
  • Packaging as jar .
  • Java version will be available based on the JDK installed on your device.
  • Name group as com. <Enter a name accordingly>
  • The default version will be ‘0.0.1’
  • You can write your project description according to your project.

Step 5: Once these things are done, click on Next .

Dependency Bootstrap

Step 6: You can leave the spring boot version as it is. Use the search box given to search for dependencies to add to the project as per your need. for the time being you can search ‘ web ‘ and select ‘ Spring web ‘ and ‘ Spring web services ‘.

Let’s say you want to perform any database operation in the project then you can go ahead and search for ‘ SQL ‘ and select ‘ Spring data JPA ‘ and ‘ MySql driver ‘. However, you can also add dependencies later using the Maven repository.

Note: Don’t add the JPA, MySQL dependencies if you don’t have MySQL configured in your system.

Step 7: Once you are done click on Finish .

Url config for spring boot project

Step 8: Now click on finish and wait till Spring boot configures all your dependencies. Now it completely depends on your device and internet speed and how much time it will take to finish the build. You can see the progress at the bottom of the window.

Package in workspace

Step 9: Once it has completed the build, go ahead and check out your project.

GFG Application

Note: You can see the @SpringBootApplication annotation in the Gfg Application.java file denoting it as a Spring Boot Application. you can change dependencies by going to the pom.xml file and adding dependencies manually from mvn repository.

Step 10: Now, right-click on the blank portion and select run as , you should get an option of Spring Boot App , select that.

Run instruction for Project

Step 11: Allow the Windows security prompt (if pops up).

Windows firewall allow

Step 12: Now wait for the deployment on the local host, you will be able to see the port number, on which the application is running. (for most cases it is 8080 ).

Console Log

Step 13: It’s showing Tomcat started on port 8080 , which means your application is running locally on port no 8080 . Now head over to your web browser and go to http://localhost:8080/ to check it.

Application Up

If you can see this Whitelabel error page that means your spring application is successfully running. As there is no controller configured for routing and no views exist that’s why this page is showing up. Now can add your controllers and views as per your requirements and run your application.

author

Please Login to comment...

Similar reads.

  • Advance Java
  • Geeks Premier League
  • Geeks Premier League 2023
  • Java-Spring-Boot
  • Best Twitch Extensions for 2024: Top Tools for Viewers and Streamers
  • Discord Emojis List 2024: Copy and Paste
  • Best Adblockers for Twitch TV: Enjoy Ad-Free Streaming in 2024
  • PS4 vs. PS5: Which PlayStation Should You Buy in 2024?
  • 15 Most Important Aptitude Topics For Placements [2024]

Improve your Coding Skills with Practice

 alt=

What kind of Experience do you want to share?

  • Enterprise Java
  • Web-based Java
  • Data & Java
  • Project Management
  • Visual Basic
  • Ruby / Rails
  • Java Mobile
  • Architecture & Design
  • Open Source
  • Web Services

Developer.com

Spring Boot is a framework and tool suite for developing and deploying Spring-based applications quickly and with very little configuration. It even comes with an embedded Tomcat Web server for running your applications as a standalone app!

Although Spring Boot is not associated with any particular IDE, being a Java tool set makes it a perfect candidate for development in Eclipse. As it happens, Spring offers the Spring Tool Suite (STS) for your favorite coding environment. Now at version 4, Spring Tools provides top-notch support for developing Spring-based enterprise applications in Eclipse, Visual Studio Code, and Atom IDE. In this tutorial, we’ll employ STS to create a basic Hello World Web app in Eclipse.

Installing STS

The easiest way to install STS is right from within Eclipse. Just select Help > Eclipse Marketplace… from the main menu and type “STS” in the search bar of the Eclipse Marketplace dialog. Once it appears in the search results, click the “install” button to proceed, as shown in Figure 1:

STS in Marketplace

Creating a New Project

STS includes its own starter project to get you started. It is accessible from the New Project Wizard. Navigate to File > New > Other… from the main menu or press Ctrl+N on your keyboard to open the wizard. In the search field, type “spring”. You’ll see the “Spring Starter Project” in the “Spring Boot” folder, as you can see in Figure 2. Select it and confirm your choice by clicking on the “Next” button:

STS Starter Package

On the New Spring Starter Project dialog, you’ll have to choose a name for your project. Let’s call it “HelloWorld”. Select Maven as the build tool, and JAR packaging and your Java version. Assign a Group of “com.developer” for the package name. Artifact is the name of the JAR file you are going to build. For example, if you use “helloworld” as the artifact, the final JAR file will be called helloworld.jar. When you’re done, your project settings should match these shown in Figure 3:

Project Settings

Click Next.

In the New Spring Starter Project Dependencies window, use the search field and type “web” into it. Then, select the Web checkbox (see Figure 4).

Project Dependencies

You can click the Finish button now. STS will create the project for you and download all of the required dependencies.

The project will contain one main Java class, called HelloWorldApplication.java, as well as a Java class for testing purposes, an empty properties file, a Maven POM file, and two files to execute the application from the command line. Figure 5 shows the project structure and the content of the main class in the editor:

Project Structure and Main Class

Setting the Request Mapping

Our app will know what content to show when we navigate to the root URL via a request mapping. Modify the SpringBootExampleApplication.java file as shown in the following code:

Running Your Application

In Eclipse, there’s no need to run the application from the command line. Just right-click your project and select Run As > Spring Boot App from the context menu, as demonstrated in Figure 6:

Starting the app

That will bootstrap the embedded Tomcat server, deploy your app, and map the URLs.

Once the application is started, launch your browser and navigate to http://localhost:8080 to see our message, as shown in Figure 7:

The app, running in a browser

Thanks to STS tooling, there’s no reason to build your Spring Boot apps from the command line. You can do all of your work within your favorite IDE.

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Latest Posts

What is the role of a project manager in software development, how to use optional in java, overview of the jad methodology, microsoft project tips and tricks, how to become a project manager in 2023, related stories.

Developer.com

sts package presentation

Show:  
   
[ ] Tue, 01 March 2016 11:38

15
June 2015

Report message to a moderator

     
[ is a reply to ] Tue, 01 March 2016 12:03

33210
July 2009
[ is a reply to ] Tue, 01 March 2016 14:56

15
June 2015

index.php/fa/25150/0/

[ is a reply to ] Mon, 07 March 2016 09:20

15
June 2015
[ is a reply to ] Tue, 08 March 2016 12:20

33210
July 2009
[ is a reply to ] Tue, 08 March 2016 13:30

15
June 2015
[ is a reply to ] Sun, 13 March 2016 11:04

33210
July 2009
[ is a reply to ] Sun, 13 March 2016 13:08

15
June 2015
[ is a reply to ] Sun, 13 March 2016 13:31

33210
July 2009
[ is a reply to ] Sun, 13 March 2016 14:07

15
June 2015
[ is a reply to ] Sun, 13 March 2016 15:39

33210
July 2009
[ is a reply to ] Sun, 13 March 2016 19:07

15
June 2015

[Updated on: Sun, 13 March 2016 19:08]

[ is a reply to ] Mon, 14 March 2016 06:47

33210
July 2009
[ is a reply to ] Mon, 14 March 2016 11:34

15
June 2015
     
Previous Topic:
Next Topic:

Powered by: FUDforum 3.0.2. Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top

Sign up to our Newsletter

A fresh new issue delivered monthly

JavaSterling

JavaSterling

Java Tutorial, Frameworks and Programs

Spring Boot Examples in STS (Spring Tool Suite)

Spring boot project in sts ( spring tool suite).

The STS (Spring Tool Suite) IDE is an eclipse-based IDE for developing the Spring Boot applications . It is the preferred IDE for importing and developing the Spring Boot Project. We can create or import Spring Boot projects in STS IDE . Let’s see some Spring Boot examples using STS IDE.

In this section, we will see:

How to Create a Spring Boot Project Using STS (Spring Tool Suite)

How to Import a Spring Boot Project Using the STS (Spring Tool Suite)

Let’s see how to create a Spring Boot project in STS IDE:

How to Create a Spring Boot Project Using STS ( Spring Tool Suite)

Below are the steps to create a Spring Boot Project using the STS:

  • Open Spring Tool Suite
  • Navigate to File menu-> New-> Maven Project
  • Select the maven-archetype-quickstart and select Next from this window.
  • Provide the Project Details
  • Configure App.java file
  • Configure pom.xml file
  • Add Java Version inside the properties of pom.xml
  • Add Dependencies in pom.xml file.
  • Create a class file
  • Define the run() method
  • Add annotations in the class
  • Run the Application

However, the above steps seem like a complicated process. But, these steps are quite simple only need some attention. The Spring Initializr provides all of the above configurations by default.

Let’s understand each step in detail:

Step1: Open Spring Tool Suite

The First step is to open the STS tool.

Step2: Navigate to File Menu-> New-> Maven Project

To create a new Spring Boot project, navigate to File Menu-> New-> other menu.

sts package presentation

Now it will open a select wizard, search for the Maven Project, and click Next to continue:

sts package presentation

Step3: Select the maven-archetype-quickstart

Now, it will open a new maven project setup. Here, we can find a variety of maven projects. For the startup, select the maven-archtype-quickstart and hit Next to continue:

sts package presentation

Step4: Provide the Project Details

in this step, enter the project details such as Group Id and Artifact Id . We have provided Group Id com. javasterling and Artifact Id spring-boot- sts-demo . Now, click on the Finish to complete the process.

sts package presentation

Now, we have created a maven project in Spring Tool Suite. The project structure will look as follows:

sts package presentation

Let’s configure it for Spring Boot.

Step5: Configure the App.java file

The App.java file can be found under the src/main/java directory within the package com.javasterling.Spring_Boot_Sts_Demo package. We don’t need to add any manual configuration to the App.java file; the following code is automatically generated:

Step6: Configure pom.xml file

A pom.xml file will be automatically generated to the Maven project. The default configuration code can be found in it:

Step7: Add Java Version in pom.xml file

Add a Java Version within the properties tag of the pom.xml file. For example, we are using Java 8, add the following statement in the pom.xml file:

<java.version>1.8</java.version>

sts package presentation

Step8: Add Dependencies in pom.xml file

To make this project a Spring Boot project, we have to add Spring Boot dependencies. Add spring boot starter parent and spring boot starter web dependencies in the pom.xml file. The parent is used to declaring that our project is a child to this parent project.

Add the following dependency within the dependencies tag in pom.xml file:

spring boot starter web:

Now, save this file by stroking CTRL+S keys. When we save this file, it will start downloading the required jar files for Spring Boot. So, make sure you are connected to the internet.

Step9: Create a class file

Now, create a class file with the name SpringBootStsDemo in the package com.javasterling. To create a file, right-click on the package, navigate to the New -> Class -> menu, and provide the class details. Click on the Finish to create.

sts package presentation

It will create a class file with the specified details.

Step10: Define the run() method

Once the class file is created, call the static method run() of SpringApplication class. Below is the code to call the static method run() and passing the class name as an argument.

Step11:Add annotations in the class

Now, add an annotation in this class by adding an annotation @SpringBootApplication.

A single @SpringBootApplication annotation enables the following annotations in our application:

  • @EnableAutoConfiguration : It enables the Spring Boot auto-configuration mechanism.
  • @ComponentScan : It scans the package where the application is located.
  • @Configuration : It allows us to register extra beans in the context or import additional configuration classes.

Now, our class file will look as follows:

SpringBootStsDemo.java:

We are all done and created our first application in STS IDE. Now, run our application.

Step12: Run Application

Now, run our application either by right-clicking on the project or the SpringBootStsDemo class file and select the Run As-> Java Application. It will produce the following output:

sts package presentation

As we can see from the output, the console is displaying that the application is up in 5.489 seconds and running.

Hence, the above guide is for developing the Spring Boot application in STS IDE. Now, let’s understand how to import a project in STS ( Spring Tool Suite).

How to Import a Spring Boot Project Using STS ( Spring Tool Suite)

To import a Spring Boot project in STS (Spring Tool Suite) is a straight forward process. Follow the below steps to import and run a Spring Boot Project:

  • Navigate to File -> Open Projects From File System
  • Browse Project From the File System
  • Select Project and Click Open
  • Run Application

To import project in Spring Tool Suite, the first step is to open it.

Step2: Navigate to File -> Open Projects From File System

Now, Navigate to the File menu-> Open projects from the file system. Select the Directory option to browse the local directory.

sts package presentation

Step3: Brose Project From File System

Now navigate the directory where you have downloaded the project and select it.

Step4: Select project and Click Open

It will select our project. Now, click Finish to complete the process.

sts package presentation

Hence, we have successfully imported a Spring Boot Project in STS. Now, it will take a while to load the dependencies and download the required files. Makes sure you are connected to an internet connection.

Now, we are ready to run our application.

Step5: Run Application

To run this project, right-click on the project and select Run As-> Java Application . It may ask you to select the Java Application. Select the SpringBootDemoApplication and hit OK to continue.

sts package presentation

It will take a few seconds to load the application content and run our project.

sts package presentation

From the above snap of output, we can see the application is up in 1.642 seconds and running.

Download Projects:

Java Guides

Java Guides

Search this blog, create spring boot project in spring tool suite [sts], 1. right-click in the package explorer and select new -> spring starter project, 2. specify project details.

  • Generate: Maven Project
  • Language: Java
  • Java Version: 1.8 (Default)
  • Spring Boot: 2.1.4
  • Group: com.springboot.tutorial
  • Artifact: springboot-helloworld-tutorial
  • Name: com.springboot.tutorial
  • Description: Demo project for Spring Boot
  • Package Name : com.springboot.tutorial
  • Packaging: jar (This is the default value)
  • Dependencies: Web, JPA, MySQL, Dev Tools

3. Project Structure

sts package presentation

Check out the complete Spring boot tutorial at  Master in Spring Boot Tutorial .

Related Spring and Spring Boot Tutorials/Guides:

Post a comment.

Leave Comment

My Top and Bestseller Udemy Courses

  • Spring 6 and Spring Boot 3 for Beginners (Includes Projects)
  • Building Real-Time REST APIs with Spring Boot
  • Building Microservices with Spring Boot and Spring Cloud
  • Full-Stack Java Development with Spring Boot 3 & React
  • Testing Spring Boot Application with JUnit and Mockito
  • Master Spring Data JPA with Hibernate
  • Spring Boot Thymeleaf Real-Time Web Application - Blog App

Check out all my Udemy courses and updates: Udemy Courses - Ramesh Fadatare

Copyright © 2018 - 2025 Java Guides All rights reversed | Privacy Policy | Contact | About Me | YouTube | GitHub

  • Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
  • Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand
  • OverflowAI GenAI features for Teams
  • OverflowAPI Train & fine-tune LLMs
  • Labs The future of collective knowledge sharing
  • About the company Visit the blog

Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Get early access and see previews of new features.

Eclipse - How to "Change package declaration to ...." across an entire project

I've just imported a large amount of source code into Eclipse and basically the package name is no longer valid (the code has been moved folders). Is there a way to select all the source code in the Package Explorer and hit a hotkey so that all package declarations are correctly resolved for me? I know you can do this with imports by selecting the source and hitting ctl-shift-o, but is also possible for the package declaration?

Update: Refactoring the packages doesn't work as I don't want to change the name or location of the packages, I just need to adjust the package declaration in the Java source code.

Vineet Reynolds's user avatar

7 Answers 7

If the package declarations are no longer valid, then all such invalid declarations would appear in the Problems view in Eclipse. If you do not see this view, you can open it from Window-> Show View -> Other... -> Problems (under the General tab).

You can filter on problems in the Problems view and correct easily correctable ones, by choosing the Quick fix option in the context menu (available on a right-click). In your case you should see something similar to the screenshot posted below:

Quick fix for incorrect packages

Applying the quick fix options is trivial, as long as you know which one is correct - you would either have to change the package declaration in the class, or the location of the class itself. Unfortunately there is no option to fix the issue across multiple units at one go; you will have to apply the quick fix for every problem.

If you want to filter on problems of only this variety, consider configuring the Problems view to show all errors that have the text content "does not match the expected package" in the error text, as demonstrated in the following screenshots:

Configure Problem Contents

  • Great response - screen shots and all ;) –  Kevin Parker Commented Aug 21, 2012 at 17:18

For this particular problem (which usually comes with auto generated artifact files), I found a neat solution.

So if the issue is that your package declarations is "package abc;" in 200 files, and you want it to be "package com.aa.bb.cc.abc;"

Then in eclipse, Search->File for "package abc;" in required folder or pkg or whole workspace. Don't select Search option but select "Replace" and then put "package com.aa.bb.cc.abc;" when it asks for the replacement after search. Should do the trick.

Manish's user avatar

  • 1 Awesome! I've used Eclipse for 7 years but never seen 'Replace...' button. –  user and Commented Jan 16, 2014 at 10:36

Right click on the package, select Refactor > Rename. This will update all source files with the new package name.

Matt MacLean's user avatar

  • 1 This doesn't work, it requires you to rename the packages. I don't want to rename or move them, I just need the "package blah.blah.blah in the source code to be updated to the right package folder. –  Stephane Grenier Commented Jul 28, 2011 at 21:14
  • @Stephane, Refactoring isn't working because refactoring doesn't fix your errors, it maneuvers code without errors to be structured differently. You should move the new package to an empty project location, refactor it to match your used blah.blah.blah package imported in your source, move it back with your source, and then you can refactor the way you want to. –  Atreys Commented Jul 28, 2011 at 21:22
  • This worked for me because I did it after I renamed the package, then went to windows operating system and renamed the folder, then came back to eclipse and rename>refactor. –  Amy McBlane Commented Apr 25, 2015 at 17:04
  • It worked for me rename it and do a rename again if you dont want to change the package name –  fjkjava Commented Jul 11, 2019 at 18:16

I just had the same problem so I wrote a bash script to do it.

The sed command used is the one on OSX. If you're using gnu sed, then you don't need the '' paramater after the -i .

Just paste it in and run it on the directory containing your source. Backup your source first unless you're very brave.

I really should start doing this stuff in a more modern language like perl :)

JohnnyLambada's user avatar

This should do the trick for you.

Import all your files into the default package first and then drag them into the new package, JDT will do the refactoring and change the package declarations across the project.

Rohit's user avatar

It is an old question, but I ran into the same problem and wrote a very simple bash script. Hope it will help someone.

Basically, the script traverses all java files inside a directory, and each occurrence of package com.example.something; replaces with package com.example.something_else; .

chao's user avatar

  • ALT+SHIFT+R add underscore at end of package name, hit ENTER twice
  • ALT+SHIFT+R delete the underscore, ENTER twice

Done if there are few packages.

Akiner Alkan's user avatar

Your Answer

Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. Learn more

Sign up or log in

Post as a guest.

Required, but never shown

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy .

Not the answer you're looking for? Browse other questions tagged java eclipse package packaging or ask your own question .

  • The Overflow Blog
  • The hidden cost of speed
  • The creator of Jenkins discusses CI/CD and balancing business with open source
  • Featured on Meta
  • Announcing a change to the data-dump process
  • Bringing clarity to status tag usage on meta sites
  • What does a new user need in a homepage experience on Stack Overflow?
  • Feedback requested: How do you use tag hover descriptions for curating and do...
  • Staging Ground Reviewer Motivation

Hot Network Questions

  • Can you move between an attack and the attack granted by Horde Breaker?
  • Why do "modern" languages not provide argv and exit code in main?
  • What is this phenomenon?
  • What are the most common types of FOD (Foreign Object Debris)?
  • is it possible to add a stepwise counter for assigning a number to each text block?
  • What qualifies as a Cantor diagonal argument?
  • Are fuel efficiency charts available for mainstream engines?
  • Minimal permutation degree of the dihedral group
  • Multiplicity of the smallest non-zero Laplacian eigenvalue for tree graphs
  • What is the missing fifth of the missing fifths?
  • Has anyone returned from space in a different vehicle from the one they went up in? And if so who was the first?
  • How would you read this time change with the given note equivalence?
  • How long should a wooden construct burn (and continue to take damage) until it burns out (and stops doing damage)
  • What is the translation of this quote by Plato?
  • How can I make this equation look better?
  • What is the resulting initiative order when a readied action triggers after a summoned monsters action but before the summoner?
  • Textile Innovations of Pachyderms: Clothing Type
  • "With" as a function word to specify an additional circumstance or condition
  • Is reading sheet music difficult?
  • Flats on gravel with GP5000 - what am I doing wrong?
  • Understanding the parabolic state of a quantum particle in the infinite square well
  • What happens on a CAN bus when impedance is too low?
  • Replacement derailleur for Schwinn
  • Generate all the free polyominoes who's width and height is no larger than 8

sts package presentation

IMAGES

  1. sts package presentation change

    sts package presentation

  2. How to create package in STS? |Package Creation

    sts package presentation

  3. PPT

    sts package presentation

  4. STS IDE

    sts package presentation

  5. STS Learning Activity Package

    sts package presentation

  6. Everything You Need to Know Before Taking The STS Exam

    sts package presentation

VIDEO

  1. Is The Funded Trader Gone Forever? Prop Firm Problems

  2. Flowrate

  3. New 2024 Mercedes-Benz Amg Gt Lynnwood WA Seattle, WA #240509

  4. Volvo SFINX

  5. CIGARETTE DAYDREAMS {NO CAPO} Cage the Elephant (Intermediate Guitar Chord Strum Play-Along) #shorts

  6. Space Shuttle Flight 3 (STS-3) Post Flight Presentation

COMMENTS

  1. How to view hierarchical package structure in Eclipse package explorer

    How to view hierarchical package structure in Eclipse ...

  2. How can I view packages as folder structure in eclipse

    Select the first package in the package explorer. Press Alt - Shift - N to open the new item context menu. Click "Package." Make sure that the new package name is a sub-package of the original package. For example, if your original package is com.example, the new package might be com.example.gui. EDIT: If you want to see the nested packages ...

  3. sts package presentation change

    how to change STS package presentation flat to hierarchical.

  4. Getting Started

    Learn how to download, install, and launch Spring Tool Suite (STS) on your platform. Follow the steps to import a Spring guide, such as Consuming Rest, and work on the code and the web page.

  5. Changing package presentation from flat to hierarchical in Eclipse

    About Press Copyright Contact us Creators Advertise Developers Terms Privacy Policy & Safety How YouTube works Test new features NFL Sunday Ticket Press Copyright ...

  6. A Guide to Spring in Eclipse STS

    Learn how to use Eclipse Spring Tool Suite (STS) to develop Spring applications with features such as project configuration, JPA query checks, jar type search and more. This article covers the basics of creating, running and debugging a Spring Boot application with STS.

  7. Creating Spring Boot Project Using STS

    Learn how to create a Spring Boot project using the Spring Tool Suite (STS), an Eclipse-based IDE for Spring applications. Follow the steps to configure dependencies, run the application and test it on localhost.

  8. Getting Started · spring-projects/sts4 Wiki

    Learn how to create and modify Spring Boot Starter Projects using various wizards in STS4, the Eclipse-based IDE for Spring developers. Find out how to use the start.spring.io webservice, edit starter dependencies, and import sample projects from spring.io tutorials.

  9. Organize Subfolders In Eclipse

    In this video, I will show a quick tip on Organize Subfolders In Eclipse #ShortsAll Playlisthttps://www.youtube.com/c/Mukeshotwani/playlistsConnect with us:E...

  10. Developing a Spring Boot Application Using STS

    Learn how to create a basic Hello World Web app with Spring Boot and STS in Eclipse. Follow the steps to install STS, create a new project, set the request mapping, and run your application.

  11. Home · spring-projects/sts4 Wiki

    Spring Tools 4 is the next generation of Spring developer tooling for Eclipse, Visual Studio Code, and Theia. Learn how to create, import, and manage Spring Boot projects, use web frameworks, work with Docker and Cloud Foundry, and more.

  12. Eclipse Community Forums: Newcomers » Package Presentation

    Steps to reproduce: 1) Open Eclipse starting C:\Program Files\eclipse\eclipse.exe. 2) Switch to JavaEE perspective if not already opened. 3) Open Package Explorer. 4) Click on the Vew Menu -> Package Presentation -> Hierarchical. 5) See the effects of this change (OK) 6) Close Eclipse. 7) Open Eclipse.

  13. Spring Boot Examples in STS (Spring Tool Suite)

    Learn how to create or import Spring Boot projects in STS (Spring Tool Suite), an eclipse-based IDE for developing Spring Boot applications. Follow the steps to configure App.java, pom.xml, and add annotations in the class file.

  14. Create Spring Boot Project in Spring Tool Suite [STS]

    Learn how to create a Spring Boot project in STS (Spring Tool Suite) with Maven, Java, Web, JPA, MySQL and Dev Tools dependencies. Follow the step by step process with screenshots and links to the complete tutorial.

  15. On Theory-Methods Packages in Science and Technology Studies

    This article reviews different theory-methods packages (TMPs) in STS, such as actor-network theory, the biography of artifacts and practices, and ethnomethodology. It analyzes how TMPs shape research designs and empirical inquiries in STS and discusses their complementarities and limitations.

  16. How to create Subpackages in sts?

    How to create Subpackages in sts? | STSTipsTricksSub package creation using Spring tool Suite smart way in easy and simple stepsFor More Videos- https://www...

  17. PDF 2. Secondary Traumatic Stress and Self-Care Packet

    Learn about secondary traumatic stress (STS), the emotional distress that results from hearing about the traumatic experiences of others, and how to promote staff self-care and resilience. Find tools, strategies, and resources for individual and schoolwide plans to address and prevent STS and related conditions.

  18. How to create package in STS [Package Creation]

    How to create package in STS [Package Creation]Spring tool Suite package creation. A new way to create package Simple and easy steps using Spring Tool Suite...

  19. java

    I know you can do this with imports by selecting the source and hitting ctl-shift-o, but is also possible for the package declaration? Update: Refactoring the packages doesn't work as I don't want to change the name or location of the packages, I just need to adjust the package declaration in the Java source code.