Issue
I am trying to generate the Swagger.json file during maven build time.
This is my plugin in pom.xml from docs.
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>pre-integration-test</id>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>post-integration-test</id>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-maven-plugin</artifactId>
<version>0.2</version>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<apiDocsUrl>http://localhost:8080/registrationprocessor/v1/registrationstatus</apiDocsUrl>
<outputFileName>openapi.json</outputFileName>
<outputDir>${project.build.directory}</outputDir>
</configuration>
</plugin>
I have seen this repo. It's running fine in the separate project but when I am trying to run in my project. It's giving java.net.ConnectException: Connection refused (Connection refused)
Full error message
[INFO] --- springdoc-openapi-maven-plugin:0.2:generate (integration-test) @ registration-processor-registration-status-service ---
[ERROR] An error has occured
java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect (Native Method)
at java.net.AbstractPlainSocketImpl.doConnect (AbstractPlainSocketImpl.java:399)
at java.net.AbstractPlainSocketImpl.connectToAddress (AbstractPlainSocketImpl.java:242)
at java.net.AbstractPlainSocketImpl.connect (AbstractPlainSocketImpl.java:224)
at java.net.Socket.connect (Socket.java:609)
at java.net.Socket.connect (Socket.java:558)
at sun.net.NetworkClient.doConnect (NetworkClient.java:182)
at sun.net.www.http.HttpClient.openServer (HttpClient.java:474)
at sun.net.www.http.HttpClient.openServer (HttpClient.java:569)
at sun.net.www.http.HttpClient.<init> (HttpClient.java:242)
at sun.net.www.http.HttpClient.New (HttpClient.java:341)
at sun.net.www.http.HttpClient.New (HttpClient.java:362)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient (HttpURLConnection.java:1253)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0 (HttpURLConnection.java:1187)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect (HttpURLConnection.java:1081)
at sun.net.www.protocol.http.HttpURLConnection.connect (HttpURLConnection.java:1015)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0 (HttpURLConnection.java:1592)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream (HttpURLConnection.java:1520)
at java.net.HttpURLConnection.getResponseCode (HttpURLConnection.java:527)
at org.springdoc.maven.plugin.SpringDocMojo.execute (SpringDocMojo.java:43)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:56)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:305)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:192)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:105)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:957)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:289)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:193)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:566)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:282)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:225)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:406)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:347)
I have tried all answers of this stackoverflow question and this github issue but unfortunately non of them working for me.
Any help will be appreciated.
Solution
Openapi.json file is generated after moving some configuration of application.properties from test folder to bootstrap.properties in src folder. But every time i have to kill port 9001 for generating json file.
Answered By - kameshsr