User Tools

Site Tools


development:optimizing_spring_builds_in_netbeans

Background

It is much faster to use a Spring-boot run maven build goal to launch the embedded tomcat container in a Spring-boot application than to use the standard NetBeans approach of packaging and (re)-deploying the application in the tomcat server on each build. The Spring-boot run approach takes under 40 secs to launch the application.

Below is an example of creating a custom build goal to launch the Spring-boot run embedded tomcat container for the WebAPI services running on a Postgresql database. It is a similar approach for other databases (specify a different database profile and connection string details).

NetBeans IDE WebAPI Project Configuration

  • Right-click on the project (WebAPI)
  • Choose Custom and then Goals…
  • in the “Run maven” dialog box that appears enter the following:

Goals

org.springframework.boot:spring-boot-maven-plugin:1.2.1.RELEASE:run "-Ddatasource.url=jdbc:postgresql://<databaseserver>:5432/<database>?user=<user>&password=<password>" "-Dflyway.datasource.url=jdbc:postgresql://<databaseserver>:5432/<database>?user=<user>&password=<password>"

Profiles

webapi-postgresql

Properties

datasource.username=<user>
datasource.password=<password>
datasource.driverClassName=org.postgresql.Driver
datasource.dialect=postgresql
datasource.cdm.database=<cdm database>
datasource.cohort.schema=<ohdsi database schema>
datasource.cdm.schema=unrestricted
datasource.ohdsi.schema=ohdsi
flyway.datasource.driverClassName=org.postgresql.Driver
flyway.datasource.username=<username>
flyway.datasource.password=<password>
flyway.locations=classpath:db/migration/postgresql
flyway.schemas=ohdsi

Important

if you want this custom goal to launch the application in debug mode then include the following property with the above list of properties

jpda.listen=maven

Check the “Remember as” checkbox and save the new custom build goal with a name like 'spring-boot run postgresql' or 'DEBUG spring-boot run postgresql' if you included the above jpda.listen=maven property to launch in debug mode.

Click OK to save the new goal.

Running the custom build goal in the NetBeans IDE

  • Right-click on the project (WebAPI)
  • Choose Custom and then choose the custom build goal that you saved in the above project configuration step

The custom build goal will start and the application will launch.

Important

If you are debugging you can use the regular debugging buttons at the top of the IDE to step through the code.

To stop running or debugging the application, click on the small red stop button on the left of the messages window in the lower center region of the IDE. The button says “stop the currently executing build” if you hover over it with your mouse.

development/optimizing_spring_builds_in_netbeans.txt · Last modified: 2015/03/05 13:47 by lee