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 > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Project example code: https://github.com/chocolateBlack/multi_env_folder_maven
The automatic deployment of the project is realized by using Maven and Jenkins, which can be packaged according to bin, conf and lib files, and can not be sent to the server according to the environment through Jenkins.
First of all, the configuration files are generated according to different environments through the Maven plug-in.
To cope with the environment switch, use the Maven attribute in the configuration file conf.yaml to determine whether to build according to the profile of id as the dev or the profile of id as the test in the project packaging process. The configurations of conf.yaml and profle are as follows:
Conf.yaml:path=$ {hdfs.path}
The configuration of profile is as follows:
Dev dev/ dev/wh/source/tp true test dev/ test/wh/source/tp
Next, you need to enable maven to parse the Maven property in the conf folder, which is what maven-resources-plugin does.
Turn on resource filtering and specify the filtered directory. The following configuration specifies that resource filtering is enabled for all types of files in the src/main/conf directory, and the parsed files are specified to be output to the target/class/conf directory
Src/main/conf/ true * * /. * conf
two。 Secondly, using the maven-assembly-plugin plug-in, the compiled project is divided into bin, conf, lib directories.
In the configuration of maven-assembly-plugin, specify a main class so that you can run the project jar package using java-jar or java-cp. In the way of jar-with-dependencies, package the dependent jar package of the project into a specified assembly.xml file in jar, which is mainly used to distribute the compiled files to the bin, conf and lib directories.
Configuration of the maven-assembly-plugin plug-in: org.apache.maven.plugins maven-assembly-plugin 2.6 make-assembly package single Com.test.HelloMaven jar-with-dependencies ${project.name} src/main/assembly/assembly.xml
About the assembly.xml configuration for file distribution:
Src/main/bin bin 755 target/classes/conf/ conf 755 unix * .formatted ${project.artifactId}-${project.version} .jar / lib/ runtime ${project.groupId}: ${project.artifactId} 755 ${project.name}-jar -with-dependencies.jar / lib/ runtime
Project structure diagram:
The configuration file in conf after being packaged with the mvn package-Pdev command is the result generated according to the dev environment
Parsed conf.yaml
Path=/dev/wh/source/tp
The structure diagram under the target directory, marked in red box, is the expected structure directory.
3. The project generates the deployment structure according to bin, conf and lib, and leaves the rest to Jenkins. Through Jenkins and its plug-ins, the package results are uploaded to the target server.
The main locations of the Jenkins configuration are described below
Under the Build tag, to instruct the-P parameter in the package command
In the operation after construction, upload the compiled bin, conf and lib directories to the server target directory through the plug-in Send build artifact over SSH plug-in
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.