In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
In this issue, Xiaobian will bring you about how to run Nacos Server in source code form. The article is rich in content and analyzed and described from a professional perspective. After reading this article, I hope you can gain something.
Curl -O https://github.com/alibaba/nacos/releases/download/1.3.2/nacos-server-1.3.2.tar.gztar-zxvf nacos-server-1.3.2.tar.gzcd nacos/bin Run # Linux/Unix/Mac startup command (standalone stands for standalone mode, non-cluster mode):sh startup.sh-m standalone#If you are using ubuntu system, or run script error prompt [[symbol not found, try the following run: bash startup.sh -m standalone# Windows startup command (or double-click startup.cmd run file) cmd startup.cmd Why do you want to source run 1. Easy to use during development
If you migrate from the Spring Cloud Netflix architecture to the Spring Cloud Alibaba technology architecture, the obvious feeling is that the entire architecture is simplified. Nacos is responsible for implementing the service discovery and configuration management parts of Spring Cloud. It is a strong dependency in the whole development process. To start the microservice business, it is necessary to check whether Nacos Server has been started. It is very inconvenient to decompress and install it.
Wouldn't it be more convenient to start Nacos Server directly as part of the entire microservices framework?
2. UI customization
If you run it unzipped, it's almost impossible to modify the UI. You can download the Nacos source code to continue to modify and then repackage to run. very inconvenient
git clone https://github.com/alibaba/nacos.gitcd nacos/mvn -Prelease-nacos -Dmaven.test.skip=true clean install -Uls -al distribution/target/// change the $version to your actual pathcd distribution/target/nacos-server-$version/nacos/bin
If you run it in source mode, you can try adjusting the UI and then build to see the effect.
3. Keep Server & Client Consistent
Pig as a microservice open source project, update iteration speed is very fast. The Nacos Client version that each version depends on may change, which means that the corresponding Nacos Server version also needs to be upgraded accordingly, which requires users to download the upgrade themselves.
Nacos has good backward compatibility with small versions, but the features of large versions change quite a lot, such as changes in permissions for 1.2 and 1.3. Therefore, it is recommended that you maintain version consistency during actual development.
If you run the source code, you can solve this problem very well.
How to achieve 1. Download Nacos source code
Just keep the nacos console module, all other modules can be deleted
2. console source code structure description <$── pom.xml ── src ├── main │ ├── java │ │ └── com │ │ └── alibaba │ │ └── nacos │ │ <$── Nacos.java # main Start Class │ │ └── console #Console related source code │ └── resources │ <$── application.properties # nacos profile │ └── static #static page directory └── test #Unit Testing Section 3. Modify Nacos.java class
Mainly add two parameters to the main method, whether it is stand-alone startup & whether to close permission verification
@SpringBootApplication(scanBasePackages = "com.alibaba.nacos")@ServletComponentScan@EnableSchedulingpublic class Nacos { public static void main(String[] args) { #Set up a standalone startup in the form of environment variables System.setProperty(ConfigConstants.STANDALONE_MODE, "true"); #Close permission check is set via environment variable System.setProperty(ConfigConstants.AUTH_ENABLED, "false"); SpringApplication.run(Nacos.class, args); }}4. Modify console/pom.xml
Since nacos bom management is no longer used, you need to add version numbers to all dependent coordinates.
Because nacos-config /nacos-naming packages are not uploaded to the central reference and cannot be downloaded, change groupId to com.pig4cloud.nacos to download
After the change, the reference is as follows
com.pig4cloud.nacos nacos-config 1.3.2 org.apache.tomcat.embed tomcat-embed-jasper 7.0.59 com.pig4cloud.nacos nacos-naming 1.3.2... The above is how to run Nacos Server in source code form shared by Xiaobian. If you happen to have similar doubts, you may wish to refer to the above analysis for understanding. If you want to know more about it, please pay attention to 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.