更改Wildfly上部署的春季项目的港口
主持人注意:其他现有问题,请参考默认接口。我对改变这一点不感兴趣。我需要专门更改每个部署的端口。
其他问题是在独立模式下运行的野生蝇。我正在作为Windows Server服务运行。
基于此,请不要解决问题。
现在,问题:
作为参考以下春季应用程序,在Windows Server 2019上以服务为服务的Wildfly运行:
@Configuration
@SpringBootApplication
public class DemoApplication extends SpringBootServletInitializer {
static Logger logger = LoggerFactory.getLogger(DemoApplication.class);
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(applicationClass);
}
private static Class<DemoApplication> applicationClass = DemoApplication.class;
}
当我使用Tomcat时,更改Web服务端口很容易添加:
application.properties
server.port = 8093
导致所需的URL:
http://127.0.0.1:8093/swagger-ui.html
但是,在Wildfly上部署被证明更难。首先,它是.war名称和错误的上下文根,我通过添加以下更改来修复:
pom.xml
<finalName>${project.artifactId}</finalName>
src \ main \ main \ webapp \ webapp \ web-inf \ jboss-web .xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web xmlns="http://www.jboss.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.jboss.com/xml/ns/javaee
http://www.jboss.org/j2ee/schema/jboss-web_5_1.xsd">
<context-root>/</context-root>
</jboss-web>
但是,这是最后一个问题。 Web服务正在 而不是使用端口8093。
如何更改Wildfly中每个部署的Web服务的端口,而不是默认的8080?
Note to moderator: Other existing questions in SO make reference to the default interface. I'm not interested on changing that. I need to specifically change the port of each deployment.
Other questions regard wildfly running in standalone mode. I'm running it as a Windows Server Service.
Based on this please do not close the question.
Now, the question:
Taking as a reference the following Spring application, running on Wildfly on Windows Server 2019 installed as a service:
@Configuration
@SpringBootApplication
public class DemoApplication extends SpringBootServletInitializer {
static Logger logger = LoggerFactory.getLogger(DemoApplication.class);
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(applicationClass);
}
private static Class<DemoApplication> applicationClass = DemoApplication.class;
}
When I was using Tomcat, changing the web service port was easy as adding:
Application.properties
server.port=8093
Resulting in the desired URL:
http://127.0.0.1:8093/swagger-ui.html
However, deploying on Wildfly proved to be harder. At first, it was the .war name and the wrong context root, which I fixed by adding the following changes:
pom.xml
<finalName>${project.artifactId}</finalName>
src\main\webapp\WEB-INF\jboss-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web xmlns="http://www.jboss.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.jboss.com/xml/ns/javaee
http://www.jboss.org/j2ee/schema/jboss-web_5_1.xsd">
<context-root>/</context-root>
</jboss-web>
However, there's the last problem. The web service is being exposed on http://127.0.0.1:8080/swagger-ui.html instead of using port 8093.
How can I change the port of each deployed web service in Wildfly, instead of the default 8080?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
server.port
属性仅控制Spring Boot应用程序中嵌入式服务器的侦听端口(Tomcat,Jetty等)。在部署期间指定了独立应用程序服务器中的应用程序端口。在Wildfly上执行此操作的最简单方法是通过
wildfly-maven-plugin
(The
server.port
property only controls the listening port of an embedded server in a Spring boot app (tomcat, jetty, etc.).The app's port in a standalone application server is specified during the deployment. The easiest way to do this on Wildfly is via the
wildfly-maven-plugin
(https://docs.jboss.org/wildfly/plugins/maven/latest/deploy-mojo.html):