服务层的pom文件配置
<resources>
<resource> <targetPath>${project.build.directory}/classes</targetPath>
/*将src/main/resources目录下的所有xml文件和properties文件拷贝到${project.build.directory}/classes文件夹下*/
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
</resource>
<!-- 结合com.alibaba.dubbo.container.Main -->
<resource> <targetPath>${project.build.directory}/classes/META-INF/spring</targetPath>
/*将src/main/resources/spring配置全部拷贝到${project.build.directory}/classes/META-INF/spring文件夹下*/
<directory>src/main/resources/spring</directory>
<filtering>true</filtering>
<includes>
<include>spring-context.xml</include>
</includes>
</resource>
</resources>
上述是通过spring container自动加载dubbo的配置
将服务层打成jar包
pom文件的插件配置
<!-- 打包jar文件时,配置manifest文件,加入lib包的jar依赖 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<!--将target/classes/下的文件打成jar包--> <classesDirectory>target/classes/</classesDirectory>
<archive>
<manifest>
<!--可执行jar的main类 阿里巴巴的dubbomain入口--> <mainClass>com.alibaba.dubbo.container.Main</mainClass>
<!-- 打包时 MANIFEST.MF文件不记录的时间戳版本(必须写) -->
<useUniqueVersions>false</useUniqueVersions>
<addClasspath>true</addClasspath>
<!--打成的jar包需要依赖别的包 都放到了lib目录下--> <classpathPrefix>lib/</classpathPrefix>
</manifest>
<manifestEntries>
<Class-Path>.</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
<!--该插件就是要解决依赖包问题-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<type>jar</type>
<includeTypes>jar</includeTypes>
<useUniqueVersions>false</useUniqueVersions>
<outputDirectory>
${project.build.directory}/lib
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
pom文件配置之后的操作
先清除项目,然后构建maven项目
本地启动jar包
java -jar jar包目录即可