dubbo笔记

使用Maven打包依赖项,启动时从本地jar中读取dubbo.xsd

最近项目用到dubbo,打包启动时报错

Failed to read schema document from http://code.alibabatech.com/schema/dubbo/dubbo.xsd

原因: 打包时没有将配置文件一并打包到jar中,所以才会去网络上找这个xsd文件

将原来打包插件 maven-assembly-plugin 改为 maven-shade-plugin pom.xml 中配置如下

打包命令: mvn package

<build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.3</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <manifestEntries>
                                        <Main-Class>com.hull.test.App</Main-Class>
                                    </manifestEntries>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                    <resource>META-INF/spring.handlers</resource>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                    <resource>META-INF/spring.schemas</resource>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
原文地址:https://www.cnblogs.com/binz/p/8080940.html