[英]How should I create a Java application.properties file for Spring?
I'm trying to set a property in a Spring application ( server.port
). 我正在尝试在Spring应用程序(
server.port
)中设置属性。 To do this, the docs says that I need a application.properties
file. 为此, 文档说我需要一个
application.properties
文件。 It says this as it is a default thing for all Java applications. 它说这是因为这是所有Java应用程序的默认设置。 So, how/where should I create this file?
那么,我应该如何/在何处创建此文件?
I've followed this answer , but I had no success creating the file under /src/main/resources/
. 我已经遵循了这个答案 ,但是在
/src/main/resources/
下创建文件没有成功。 Is it missing a reference? 是否缺少参考?
EDIT: I had no success because the application still loads using port 8080 instead of the port that I've defined in the configuration file. 编辑:我没有成功,因为应用程序仍然使用端口8080而不是我在配置文件中定义的端口进行加载。
考虑到您正在运行Spring Boot,请转到application.properties
,然后进行设置
server.port=8081
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.