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/02 Report--
This article shows you how to create a springboot project in java. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.
You can choose whether to build with maven or gradle
No matter which way to build, the management of the jar package or those three coordinates, groupId, artifactId,versionId, plug-ins are also based on these three coordinates. But the syntax of the two management is different, and then I did not study the details, gradle domestic information is relatively few, but the famous spring source code is also built with gradle, so friends who like to toss can try gradle.
SpringBoot version
The snapshot version with SNAPSHOT may not be perfect, and the non-SNAPSHOT version is generally chosen.
Project coordinates
Just like every jar package has three coordinate values, our project will be packed into a jar package or a war package in the future, and the same coordinates are needed. Group is generally used as the project name (com.fenxiangtech.boot), artiface is generally used as the module name (study), click # 5 and you can see the version option. Generally, developers use SNAPSHOT.
Project dependence
As students who used to develop with spring know, you have to find dependencies everywhere for a function, and then copy dependency into pom.xml. Springboot packages a functional dependency jar package. Only one dependency can be used to solve the problem. You can choose common functional modules, such as mybatis, redis, jdbc, web, and so on.
Switch to full mode
You can see options such as switching java versions in full mode. Java 11 is recommended and learn from the latest, which is a long-term supported version. I will definitely switch to this version in the future.
One-click generation
After all is selected, you can generate a simple runnable program with one click. You can choose whatever you want and have a try.
Our primary extension is to generate a runnable program with one click and run it!
The knife of the pilot test
Friends, if you still remember the article "Dream of the java Story", we mentioned the builder model in it. Now let's take a look at this springboot generation process, whether it is also very similar to the builder model, first with various configurations, and the last build generation is done, so our intermediate extension is to use the builder mode to simulate the one-click generation of springboot.
Think about it carefully, there are so many options for various configurations, and there are too many possibilities to combine them together, so do we have to write so many methods in our director class, so it should not be pure builder mode? if we were to do this, what would we do? Find a template, empty the corresponding location, initialize a few Map, and match the selected configuration with the code to be put in the file, so as to change the template according to the selection of the page, define a prototype, and then modify it according to the selected configuration, so that there will not be so many ways, this is the prototype mode?
Later, when I think about it, this is actually just a generated file. If you write the code directly without any design pattern, it will be a judgment. However, according to the configuration value, the file will be generated, packaged into zip, and then returned by response. So a function can be implemented in many ways, and interested partners can try it for themselves.
A big test.
As we mentioned above, springboot helps simplify the dependency and configuration of spring. In the past, we used all kinds of injections in spring, but now we only need to configure it in application.perporty in springboot. We can think deeply about how springboot does it.
First of all, dependencies must be managed with the help of maven/gradle, so the starter project should also be a maven/gradle Springboot program. Define dependencies in pom.xml. What are the definitions? Definition can be automatically configured, details can be Baidu or their own practice, in the official account of the knife, there has never been a direct copy of what can be used, throw a brick to attract jade, or hope that we can think together, so that we can make progress
Then configure the class, define the prefix, give default values, and so on, using @ ConfigurationProperties
There are configurations and dependencies. Next, we need to load the configuration, initialize the instance, and prepare for the work. Many of us can use the functions directly after referencing starter without configuring bean. This is the step where bean is assembled and instantiated in starter, so we can directly use it.
Finally, you use spring.factories to tell spring which classes to assemble automatically. As the idea above, the extension is to implement a starter of Springboot by yourself.
The above is how to create a springboot project in java. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
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.