In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/03 Report--
As we all know, one of the most attractive things about SpringBoot framework is that it provides default configurations for various framework component integrations, and "zero configuration" integration and development is its ultimate goal. In theory, you can start a project without any special configuration.
If you use SpringBoot for web project development, then it has embedded web containers, you do not need to deploy to tomcat or jetty containers separately, packaged into jar packages to run, eliminating the locking packaging deployment process. By default, web projects started by SpringBoot have a default port of 8080, which is also the default port for tomcat or jetty. Then the problem comes. What should I do if I change the port? This is an inevitable problem.
Remember the main method you needed to write to run SpringBoot, which looked like this:
@SpringBootApplicationpublic class Application { public static void main(String[] args){ SpringApplication.run(Application.class, args); }}
Note that this is a main method that dynamically passes in startup parameters, which is no different from running a java program. args is its startup parameter, which is an array that can take one or more parameters.
So what does this parameter do? Since springboot does most of the configuration by default, to modify this configuration, the parameters passed into the main method override the configuration that the framework automatically does for you.
For example, you can modify the port on which you launch your project with code similar to:
java -jar xxx.jar --server.port=8888
For example, you can modify the logo of the console output of the project you started with code similar to
java -jar xxx.jar --spring.banner.location=classpath:banner.txt
The final effect is to turn on the startup, which you often see.
replaced by this:
There are many other default settings that can be customized like this, although some require module dependencies in the pom file to use the functionality. For example, if you use redis, then you need to add
spring-boot-starter-data-redis to load the default settings of redis first. On this basis, you can write custom parameters, such as:
java -jar xxx.jar --spring.redis.port=6379
Note that the format of the command is:
#Parameters need to start with--after jar package name java -jar xxx.jar --parameter name = parameter value
You can also add multiple custom parameters (separated by spaces) at runtime, such as combining the above examples:
java -jar xxx.jar --server.port=8888 --spring.banner.location=classpath:banner.txt --spring.redis.port=6379
Theoretically, any parameter that can support customization can be added.
Incidentally, this is how IDEs like IDEA or Myeclipse work when they help you run projects.
Now, two problems arise.
How do I know which custom parameters Springboot supports?
2. So many parameters, are they written on the operation command? Wouldn't that make it look bloated and not elegant at all?
These two questions will be discussed next time.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.