Introducing Cline

For this course I am going to provide a free AI coding assistant that you can use to help you write Spring Boot applications. The coding assistant consists of a pair of large language models that I have set up. You will be using the Cline extension in Visual Studio Code to access this models.

To install Cline, click on the extensions tab in Visual Studio Code and type 'Cline' into the search box. Once you have the Cline extension installed you will see a Cline tab appear in the left tab bar.

Click on the Cline tab. Cline will prompt you for some initial set up information. Choose the option to use your own API key, then open the Cline settings by clicking the gear icon in the Cline pane.

Enter the following settings:

API Provider: LM Studio
Turn on the option 'Use custom base URL' and enter the URL 
http://143.44.10.188:1234/
Model: qwen/qwen3-coder-next

Click the Done button to activate these settings.

A database for an events application

Events Database

In the example below I am going to use Cline to construct a simple Spring Boot application. The application will work with an events database. Click the button above to download the database files you will need for this.

Create a new, empty schema named 'events' in the MySQL workbench, and then import the database files I provided.

Setting up a project folder

Create a new, empty folder somewhere on your computer and then open that folder in Visual Studio Code. Make sure that this is the only folder you have open in VS Code.

The first prompt we will give Cline asks it to set up the intial project structure:

Create a new Spring Boot application using Spring Boot 4.0.5 with Java 25. 
The application will use Spring JDBC and Spring Web and will work with a local MySQL server. 
Use the user name 'student' and password 'Cmsc250!' to connect to a MySQL database named 'events'. 
Create only the application class. Do not create any other classes just yet.

Cline will prompt you several times along the way to approve and save files it creates. It will make a pom.xml file, an application.properties file, and a Java file with the Application class.

Supplying information about the database tables

Next we will ask Cline to create a couple of Java classes whose structure mirrors the structure of the two database tables. To do this we need to have the database installed in MySQL and then use the database export feature to dump a couple of SQL files into the project folder that describe the structure of the database tables. When you do the database export from the MySQL workbench, make sure to select the 'Dump Structure Only' option.

We can add these SQL files to our prompt by clicking the @ button in the task pane. After clicking the @ button select the option

Add a couple of Java classes to model the structure of the following two database tables:

 @/events_events.sql 
 @/events_registrations.sql

Completing the application

Finally, we will ask Cline to add a controller class with three routes. Our coding model should be able to figure out that it also needs to add repository classes to support the controller class.

Make a controller for this application that supports three routes:

1) GET a list of all events
2) POST a new registration
3) GET a list of the registrations given the id of an event.

Fixing a bug

The final task is complex enough that Cline may not succeed in all of the necessary steps. Cline should end its work by running some tests, or at least by giving you a list of commands to run in the terminal to test the application.

One of those tests, the test to POST a new registration, may fail. If Cline has asked you to run these tests and that test fails, you will need to tell it in a prompt that the test to POST a new registration failed. Cline may ask you some questions about what went wrong. Once it has enough information it should go to work fixing the error.

Using Plan Mode

For more extensive examples you may find it helpful to use Cline's plan/act method. In this approach we start by asking Cline to develop a plan for what needs to be done. Once we are satisfied with the plan we switch to act mode and Cline does the work needed to execute the plan.

To support the plan/act approach I have set up a second large language model that is bettter suited for generating action plans. To set up Cline to use this second model for the planning stage, open the Cline settings and click the Plan Mode tab. Enter these details there:

API Provider: OpenAI Compatible
Base URL: http://cmsc106.net:2345/v1
OpenAI Compatible API Key: <Use the key I emailed you>
Model ID: nvidia/nemotron-3-super

Click Done to save your setting changes.

Once again will will need to add SQL files to the prompt to give Cline enough information about the database table structure. To do this, make sure that the SQL files are in the project folder and then use the @ trick in the prompt to add the files to the context.

Here is an example prompt I used to have Cline build the entire example application in one go. To run the prompt, switch to plan mode:

I would like to build a Spring Boot application using Spring Boot 4.0.5 with Java 25. 
The application will use Spring JDBC and Spring Web and will work with a local MySQL server. 
Use the user name 'student' and password 'Cmsc250!' to connect to a MySQL database named 'events'.

Here is the structure of the two tables in the database:

 @/events_events.sql 
 @/events_registrations.sql 

Make a controller for this application that supports three routes:

1) GET a list of all events
2) POST a new registration
3) GET a list of the registrations given the id of an event.

Once Cline has generated a plan, click the Act tab to switch to Act mode. This will cause Cline to execute the plan it has generated. Cline will prompt you several times along the way to save files it has generated. Once all of the files are in place Cline will start the Spring Boot application and run a couple of simple tests in the terminal to confirm that the three requested routes work correctly.