springboot 启动文字 设置网址
时间: 2023-11-15 18:04:11 浏览: 51
您可以在 Spring Boot 的配置文件中设置服务器的端口和上下文路径,以及您想要展示的欢迎页面。例如,在 application.properties 文件中,您可以添加以下代码:
```
server.port=8080
server.servlet.context-path=/myapp
spring.mvc.view.prefix=/WEB-INF/views/
spring.mvc.view.suffix=.jsp
```
这将设置您的应用程序在本地主机的端口 8080 上运行,并将上下文路径设置为 /myapp。您还可以将视图文件的位置设置为 /WEB-INF/views/,并指定视图文件的后缀为 .jsp。然后,您可以创建一个名为 index.jsp 的欢迎页面,并将其放置在 /WEB-INF/views/ 目录下。
在完成上述设置后,您可以在浏览器中输入 http://localhost:8080/myapp 来访问您的应用程序,并显示您的欢迎页面。
相关问题
springboot 启动文字
当 Spring Boot 应用程序启动时,控制台会输出很多信息,包括应用程序的端口、自动配置信息等。一般来说,控制台输出的信息应该类似下面这样:
```
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.4.RELEASE)
2021-01-01 00:00:00.000 INFO 1234 --- [ main] com.example.demo.Application : Starting Application on my-computer with PID 1234 (C:\path\to\application.jar started by user in C:\path\to)
2021-01-01 00:00:00.000 INFO 1234 --- [ main] com.example.demo.Application : No active profile set, falling back to default profiles: default
2021-01-01 00:00:01.000 INFO 1234 --- [ main] com.example.demo.Application : Started Application in 1.234 seconds (JVM running for 4.567)
```
这些信息包括:
- 应用程序的名称和版本号(上面的 `Spring Boot` 和 `v2.3.4.RELEASE`)
- 应用程序的启动时间和日期(第三行 `2021-01-01 00:00:00.000`)
- 应用程序的主类和 PID(第二行 `com.example.demo.Application on my-computer with PID 1234`)
- 应用程序的配置文件信息(第四行 `No active profile set, falling back to default profiles: default`)
- 应用程序启动所需时间(最后一行 `Started Application in 1.234 seconds (JVM running for 4.567)`)
springboot 启动文字 如何配置
在 Spring Boot 中,可以通过修改 `application.properties` 或 `application.yml` 文件来配置启动时的文字。
如果使用 `application.properties` 文件,则需要在文件中添加以下行:
```
spring.banner.location=classpath:banner.txt
```
这会告诉 Spring Boot 在 classpath 下查找名为 `banner.txt` 的文件,并将其用作启动时的文字。
如果使用 `application.yml` 文件,则需要添加以下行:
```
spring:
banner:
location: classpath:banner.txt
```
同样,这会告诉 Spring Boot 在 classpath 下查找名为 `banner.txt` 的文件,并将其用作启动时的文字。
在 `banner.txt` 文件中,可以编写任何自定义的 ASCII 艺术字或图像。例如:
```
____ _ _
/ ___| ___ ___| | _____ _| |_ ___
\___ \ / _ \ / __| |/ / _ \/ __| __/ __|
___) | (_) | (__| < __/ |_| |_\__ \
|____/ \___/ \___|_|\_\___|\__|\__|___/
```
这样启动应用程序时,就会在控制台上显示这个自定义的 ASCII 艺术字。