In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "how to output maven multi-module projects into a component". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Desktop production line my maven code engineering xxx display xxx-web host xxx-app keyboard xxx-domian mouse xxx-infrastration desktop xxx-all.jar
Although not exactly corresponding, I use the open source dubbo to describe my problem.
Dubbo developer: dubbo's open source project uses maven multi-module development, the internal module is divided into very fine.
Make full use of the sub-module design idea of desktop computer.
Dubbo users: I only need to introduce a dubbo-all dependency to use dubbo
Just like desktop users, all I need is a usable desktop, according to the user's manual. I don't want to know what's inside.
You only need to introduce coordinates:
Com.alibaba dubbo 2.7.0 true background
Recent business development work has encountered a similar problem.
Answer the question, where are we? Current common component programmer development uses multiple modules to develop a component, while business programmers want to reference only one component where are we go? Aim to develop a common component with multiple modules, and a business project only needs to introduce a module how we go there? Implement path maven-shade-plugin implement path shade
Shade provides the ability to package your maven multi-module artifacts and component dependencies into a super jar package.
It is bound to the package phase of the maven life cycle and provides a unique goal instruction shade:shade for mavn
Its system operating environment requirements are:
Operation requirements indicate that there is no minimum space requirement for maven3 minimum maven3jdk7 minimum jdk7 memory and disk
The usage is as follows:
Org.apache.maven.plugins maven-shade-plugin 3.2.4 org.apache.maven.plugins maven-shade-plugin 3.2.4 package shade
Common configuration properties:
ApacheLicenseResourceTransformer
Prevent duplicate certificates
ApacheNoticeResourceTransformer
Prepare merge Notification
AppendingTransformer
Add as a resource
ComponentsXmlResourceTransformer
Aggregate components.xml from
DontIncludeResourceTransformer
Exclude resource files
IncludeResourceTransformer
Included resource files
ManifestResourceTransformer
Entry for manifest
ServicesResourceTransformer
Merge meta-info/services resources
XmlAppendingTransformer
Add xml content as a xml resource dubbo
It mainly depends on the configuration of dubbo-all module:
4.0.0 org.apache.dubbo dubbo-parent ${revision}.. / pom.xml dubbo jar dubbo-all The all in one project of dubbo org.apache.dubbo dubbo-config-api ${project.version} compile true Org.apache.maven.plugins maven-shade-plugin package shade True false com.alibaba:hessian-lite Org.apache.dubbo:dubbo-config-api META-INF/dubbo/internal/org.apache.dubbo.common.compiler.Compiler META-INF/dubbo/internal/org.apache.dubbo.common.config.configcenter.DynamicConfigurationFactory Org.apache.dubbo:dubbo com/** org/** META-INF/dubbo/**
In order to control that the code takes up too much content, the pom posted above is configured to delete a large number of the same or similar nodes. Let's disassemble its structure:
The core node indicates that the dependency is directly dependent, that is, the included module pluginshade in the current project
Core configuration of shade
Configuration instructions (see name, guess first) phase hookup in the package phase of the life cycle of maven goal provides unique goal instructions shadecreateSourcesJar whether to create the source code into the jar package, it is convenient for ide to see whether the source code promoteTransitiveDependencies is packaged indirectly dependent on the sub-modules contained in artifactSet-includes-include or excluded sub-modules transformers-transformer-resource converter configuration excludes >-filter filter to discharge some files
Look at the code above.
This is the end of the content of "how to output a maven multi-module project as a component". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.