@m_rastegar and I spent some time today reviewing the integration points for the KnowledgeBase integration into the WebAPI. He is using Eclipse for his development environment and is trying to launch using the embedded Tomcat, much like how I do in NetBeans. One thing he was not clear on was how to configure his local environment to override the pom settings. Is that something @alfranke or @cahilton could assist with?
We use STS, which is Eclipse-based, and feels just like using Eclipse (to me). It has some extra Spring tools built in (see more in link above). For running WebAPI, I just right-clicked on the project and clicked ‘Run as Spring Boot project’. It knew exactly what to do and set up a Run Configuration for me.
I guess I haven’t used an embedded tomcat in regular Eclipse, but you can run the project the normal Eclipse/Tomcat way (setting up a server in Eclipse, deploying that war to tomcat). However, @alfranke might have setup an embedded tomcat in non-STS Eclipse.
A way to override default properties (in the pom), would be to add a profile like below to settings.xml. Note that the below properties are based on the JPA branch and include the change in property name prefixes for datasource-related props. So, to use the exact properties below you would have to be working on a branch that includes the JPA. Hopefully, we can merge this into master soon.
Note: in Eclipse, every time you update your settings.xml, you have to “reload/update” Eclipse (Window->Preferences->maven->user settings-> update settings). Then you will need to right-click your project->maven->update project). This will ensure eclipse/maven filters the properties.
<profile>
<id>webapi-postgresql</id>
<properties>
<datasource.driverClassName>org.postgresql.Driver</datasource.driverClassName>
<datasource.url>jdbc:postgresql://54.209.111.128:5432/vocabularyv5</datasource.url>
<datasource.username>USER</datasource.username>
<datasource.password>PASS</datasource.password>
<datasource.dialect>postgresql</datasource.dialect>
<datasource.cdm.schema>unrestricted</datasource.cdm.schema>
<datasource.ohdsi.schema>ohdsi</datasource.ohdsi.schema>
<datasource.cohort.schema>ohdsi</datasource.cohort.schema>
<flyway.datasource.driverClassName>${datasource.driverClassName}</flyway.datasource.driverClassName>
<flyway.datasource.url>${datasource.url}</flyway.datasource.url>
<flyway.datasource.username>userWithWritesToOhdsiSchema</flyway.datasource.username>
<flyway.datasource.password>PASS</flyway.datasource.password>
<flyway.locations>classpath:db/migration/postgresql</flyway.locations>
<!-- Note: Schema name is case-sensitive. -->
<flyway.schemas>${datasource.ohdsi.schema}</flyway.schemas>
</properties>
</profile>
Regarding running the application, you can “run on server” which will be comparable to the way Frank & Chris run it, in that eclipse will deploy to a tomcat instance (found on the servers view within eclipse). Charity mentioned a way to run it as a “spring boot application”. This will use the mvn spring-boot:run
under the covers. In Eclipse, you can also run the org.ohdsi.webapi.WebApi class as a Java application (right-click, run as java application). This is how I run it and I’ve found it to have a quicker startup time than the other methods. This method (and the spring-boot:run method) uses an embedded tomcat (no external tomcat server needed). Note that this “embedded” tomcat is different than the using tomcat in eclipse/netbeans.
I was not able to quickly find an alternative to ‘run as java application’ in netbeans. It seems netbeans always wants to run with Maven commands/goals. I don’t really care for how Netbeans has configured the project. If one can’t make the change from Netbeans to Eclipse, I may recommend creating a custom action to run the spring-boot:run
goal. This seemed to be faster than the “run project” method of undeploying/deploying to tomcat.