我目前正在尝试创建一个带有Spring的web应用程序。我需要将我的应用程序托管到本地主机:8081。怎么换港口?
发布于 2015-05-13 15:42:34
实际上,您想要更改server.port,并且可以通过许多不同的方式更改它,如所描述的http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-external-config
示例:
还有更多
发布于 2017-03-08 21:34:46
默认情况下,spring引导使用端口8080,但只需在main()中添加以下代码行,就可以更改端口,如下所示:
System.getProperties().put( "server.port", *YOUR_PORT_NUMBER_GOES_HERE* ); e.g
@SpringBootApplication
public class MyClass {
public static void main(String[] args) {
System.getProperties().put( "server.port", 8181 ); //8181 port is set here
SpringApplication.run(MyClass.class, args);
}或
您可以在application.properties文件中配置它,如下所示:
server.port=8181如果您的spring引导应用程序中没有application.properties文件,那么可以继续创建一个文件。右键单击src/java/resources文件夹并转到New-> Other-> General并选择“File”,然后将名称命名为:application.properties
您可能需要的任何其他配置都在这里列出,https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html。这些属性也是在application.properties文件中配置的。
发布于 2015-10-28 10:14:47
实际上,您想要更改server.port,并且可以通过许多不同的方式更改它,如所描述的http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-external-config
将server.port=9000放在application.properties中
https://stackoverflow.com/questions/30219255
复制相似问题