如何更改hpi的端口号:运行

时间:2019-02-06 08:10:09

标签: java eclipse maven jenkins

我正在尝试运行以下命令将hpi文件打包到目标文件夹中

 hpi:run

并观察到以下错误消息,指出该端口已被使用。我只是试图通过手动杀死端口,但是我没有特权这样做。是否可以通过将-Dhpi.port = xxx作为参数来自定义端口号?

例外:

  

java.net.BindException:地址已在使用中:绑定在   sun.nio.ch.Net.bind0(本机方法)位于   sun.nio.ch.Net.bind(Net.java:433)在   sun.nio.ch.Net.bind(Net.java:425)在   sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)     在sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)     在   org.eclipse.jetty.server.ServerConnector.open(ServerConnector.java:321)     在   org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)     在   org.eclipse.jetty.server.ServerConnector.doStart(ServerConnector.java:236)     在   org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)     在   org.eclipse.jetty.maven.plugin.MavenServerConnector.doStart(MavenServerConnector.java:120)     在   org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)     在org.eclipse.jetty.server.Server.doStart(Server.java:366)   org.eclipse.jetty.maven.plugin.JettyServer.doStart(JettyServer.java:73)     在   org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)     在   org.jenkinsci.maven.plugins.hpi.AbstractJettyMojo.startJetty(AbstractJettyMojo.java:567)     在   org.jenkinsci.maven.plugins.hpi.RunMojo.startJetty(RunMojo.java:660)     在   org.jenkinsci.maven.plugins.hpi.AbstractJettyMojo.execute(AbstractJettyMojo.java:390)     在org.jenkinsci.maven.plugins.hpi.RunMojo.execute(RunMojo.java:353)     在   org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)     在   org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)     在   org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)     在   org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)     在   org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)     在   org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)     在   org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)     在   org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)     在org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)处   org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)在   org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)在   org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)在   org.apache.maven.cli.MavenCli.main(MavenCli.java:141)在   sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)位于   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     在   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     在java.lang.reflect.Method.invoke(Method.java:498)在   org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)     在   org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)     在   org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)     在   org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)   2019-02-06 13:34:37.404:警告:oejuc.AbstractLifeCycle:main:FAILED   org.eclipse.jetty.maven.plugin.JettyServer@4802791f:   java.net.BindException:地址已在使用中:bind

1 个答案:

答案 0 :(得分:0)

摘自Jenkins文档:

  

在当前插件项目中运行Jenkins。   这只需要编译源文件,因此在编译时运行   阶段。
  要指定HTTP端口,请使用-Djetty.port = PORT

因此,请尝试使用-Djetty.port=PORT参数。