Spring Boot项目中的application.properties文件在哪里? [英] Where is the application.properties file in a Spring Boot project?

查看:1250
本文介绍了Spring Boot项目中的application.properties文件在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我启动了一个新的Spring启动项目,我想更改端口号,我读到我必须修改 /resource/application.properties 才能这样做。

I started a new Spring boot project, I want to change the port number and I read that I have to modify the /resource/application.properties to do so.

我找不到这个文件但是,我错过了什么吗?我需要安装启动启动器吗?我不想使用spring CLI设置它。

I cannot locate this file however, did I miss something? Do I need to install a boot starter? I don't want to set this using the spring CLI.

我应该手动创建此文件吗?如果是这样,我想我必须将此文件标记为代码中的某个属性文件。那会是哪里?

Should I create this file manually? If so, I think I'll have to mark this file as the properties file somewhere in the code. Where would that be?

非常感谢!

推荐答案

你将需要在类路径中添加 application.properties 文件。

You will need to add the application.properties file in your classpath.

如果你使用的是Maven或Gradle,你可以把文件放在 src / main / resources 下。< br>
如果您没有使用Maven或任何其他构建工具,请将它放在您的src文件夹下,您应该没问题。

If you are using Maven or Gradle, you can just put the file under src/main/resources.
If you are not using Maven or any other build tools, put that under your src folder and you should be fine.

然后您可以添加属性文件中的条目 server.port = xxxx

Then you can just add an entry server.port = xxxx in the properties file.

这篇关于Spring Boot项目中的application.properties文件在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆