服务化代码层次结构
一、采用mvn生成对应的包
自动将项目依赖的jar包打到web-inf 下的lib文件夹中
jar, 使用 maven的 assembly插件, 会在${project}/target 文件夹下发现新生成的 {artifactId}-jar-with-dependencies.jar 这个文件
二、如何配置assembly插件
标红部分
< project xmlns = "http://maven.apache.org/POM/4.0.0" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" >
< parent >
< artifactId > dubboparent </ artifactId >
< groupId > com.ai </ groupId >
< version > 0.0.1-SNAPSHOT </ version >
</ parent >
< modelVersion > 4.0.0 </ modelVersion >
< groupId > com.ai </ groupId >
< artifactId > dubboservice </ artifactId >
< version > 0.0.1-SNAPSHOT </ version >
< name > dubboservice </ name >
< url > http://maven.apache.org </ url >
< properties >
< project.build.sourceEncoding > UTF-8 </ project.build.sourceEncoding >
</ properties >
< dependencies >
< dependency >
< groupId > com.ai </ groupId >
< artifactId > dubbodao </ artifactId >
< version > 0.0.1-SNAPSHOT </ version >
</ dependency >
< dependency >
< groupId > org.apache </ groupId >
< artifactId > zookeeper </ artifactId >
< version > 3.4.5 </ version >
</ dependency >
< dependency >
< groupId > org.I0Itec.zkclient </ groupId >
< artifactId > zkclient </ artifactId >
< version > 0.1 </ version >
</ dependency >
</ dependencies >
< build >
< plugins >
< plugin >
< groupId > org.apache.maven.plugins </ groupId >
< artifactId > maven-compiler-plugin </ artifactId >
< version > 2.3.2 </ version >
< configuration >
< source > 1.6 </ source >
< target > 1.6 </ target >
< encoding > UTF-8 </ encoding >
</ configuration >
</ plugin >
<plugin >
<artifactId >maven-assembly-plugin </artifactId >
<version >2.2-beta-5 </version >
<configuration >
<descriptors >
<descriptor >src/main/assembly/src.xml </descriptor >
</descriptors >
</configuration >
</plugin >
</ plugins >
</ build >
</ project >
(2) 在 main/assembly 下创建 src.xml文件,其中src.xml中的内容
< assembly
xmlns = "http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd" >
< id > jar-with-dependencies </ id >
< formats >
< format > jar </ format >
</ formats >
< includeBaseDirectory > false </ includeBaseDirectory >
< dependencySets >
<dependencySet >
<unpack >false </unpack >
<scope >runtime </scope >
</dependencySet >
</ dependencySets >
< fileSets >
< fileSet >
< directory > ${project.build.outputDirectory} </ directory >
</ fileSet >
</ fileSets >
</ assembly >
(3)命令行输入mvn assembly:assembly
会在 ${project}/target 文件夹下发现新生成的 {artifactId}-jar-with-dependencies.jar 这个文件
(4) 下载对应的依赖包并查看