How can I run a Spring REST service in the IntelliJ debugger (built via maven) - spring

I am able to build the Sprint RESTful server and then run the server from the command line using:
java -jar rest-service-0.0.1-SNAPSHOT.jar
But how can I run it under the IntelliJ debugger? In IntelliJ in the Maven Projects window it includes Lifecycle choices of: package, site, & deploy but none of these if run under the debugger actually start the server.

Related

Jhipster Webpack failure for Jhipster Maven Microservice Gateway application in Dev environment

I have generated a Sample Microservice application and a Microservice gateway application using Jhipster. Both applications are built using maven and are using Jhipster registry for identification and routing. I am successfully able to build the Micro service application and able to reach it in the assigned localhost port.
I have build issues while building ./mvnw for gateway application. But it builds properly for gradle application and the API's are up. I have issues only for maven in org.springframework.boot:spring-boot-maven-plugin:2.0.5.
Its running on Windows 10 machine, latest version of Jhipster.
Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.5.RELEASE:run (default-cli) on project api-contact-gateway: Could not exec java: Cannot run program "C:\Program Files\Java\jdk1.8.0_181\jre\bin\java.exe": CreateProcess error=206, The filename or extension is too long
I have debugged further and could see that the Classpath passed as a part of JVM arguments is too long. But my system variables are properly set.
I coudn't find any specific solution. I just lowered my Jhipster version to 4.14

Running API tests in Teamcity build step

I have a Spring Boot Maven app. There is a bunch of API tests using RestAssured, inside the project. These tests are not marked as #SpringBootTest, therefore when running them, the context of the application is not raising so to make tests pass the application must be up and running before.
I'm creating a Teamcity build in which I want to:
Start the app
Run RestAssured tests
Create an artifact
I'm using an Agent with maven installed.
The question is:
How can I create a build step where I run the application on a defined port and then run api tests
against it?
What I've tried is creating such build steps:
Command line: mvn spring-boot:run & sleep 50s mvn test
Maven step/command line: mvn clean package -DskipTests
I thought the spring boot application will start and tests will be ready to start after some time. On successful step 1 I create an artifact.
The problem is that the build step is never exited because of spring boot app running (blocking terminal).

How to integrate maven framework with Jenkins

In order to integrate and run the Selenium Maven project on Jenkins 2.73.3, I set the option(s) as the following images:
Notice Goals and options with clean install; nothing else selected/checked, but Enable triggering of downstream projects.
Notice Install automatically is unchecked.
Jenkins project built successfully without opening any browser that shows any activity.
Please, let me know if there is/are any project setting(s) to solve this issue; i.e.: can we see the Web application run on browser as it does when it's run by the Maven project.
You are using Jenkins from services means you are using installable Jenkins version which not allow opening of any UI invocation.
You need to use jenkins.war
You can download war from below URL:
https://updates.jenkins-ci.org/download/war/
Use below command to start Jenkins server
java -jar jenkins.war --httpPort=9090

How to test a web application with jUnit/selenium from Jenkins that is deployed outside maven (in this very Jenkins)

I have to test a webapp, that is build with maven from Jenkins as CI. The Jenkins instance deploys the webapp via script as 'post build step' to a test enviroment. After the deployment some integration tests should be fired and the results should go back to the jenkins instance.
I can't let maven itself deploy the webapp and utilize surefire/failsafe, because I am not allowed to do so.
I already have a little java app, that uses Selenium WebDriver to perform JUnit tests. I could run this app as 'post build step' like this:
java -cp /usr/share/java/junit.jar junit.textui.TestRunner [test class name]
but I have no ideas how to include dependecies (probably somehow like this: Selenium Scripts on the command line) and how to get the results back to Jenkins.

Maven jetty or tomcat plugin with hot deploy option including dependencies

I have a maven project with root module called "sample" and two child modules in their own directories "sample-services" and "sample-web". "sample-web" is a war module which depends on "sample-services"
I want to be able to run my server from maven (it could be jetty, tomcat, or any lightweight server) and debug my code without using eclipse or intellij idea j2ee integration (for example in Intellij Idea community edition or other IDE that supports remote debugger) and just by adding a remote debugger.
I could start my app with "jetty:run" and attach the debugger but the problem is that when I change my code in "sample-services" it doesn't pick it up unless I run "mvn install" on that module separately and restart the server.
Is there a better way to be able to debug the app and have the server redeploy the code changes without having to restart the server?
I know eclipse can do this for a maven project. It will detect the changes in dependent project and upload them to the server.
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.0.3.v20130506</version>
</plugin>
EDIT:
I ended up using tomcat maven plugin for now:
org.apache.tomcat.maven
tomcat7-maven-plugin
2.1
/
true
in your pom.xml and run in the command line: mvn tomcat7:run
Downside is that this will reload the whole app upon each change instead of hot-deploy.
So now I am looking for a hot deploy alternative.

Resources