一、dubbo的main启动在使用上面会简单的多,但是需要做一些简单的配置。

dubbo.spring.config=classpath*:META-INF/spring/*.xml

  备注:这个是默认配置:需要修改的可以自己建立dubbo.properties修改对应路径。当然在pom.xml中也可以配置。

  二、pom.xml配置

<build>  
        <!-- 名称 -->  
        <finalName>edu-service-user</finalName>  
  
        <resources>  
            <!--这里是将[directory]目录下面的[includes]中设定的所有配置打包进 [targetPath]这个里面去 -->  
            <resource>  
                <targetPath>${project.build.directory}/classes</targetPath>  
                <directory>src/main/resources</directory>  
                <filtering>true</filtering>  
                <includes>  
                    <include>**/*.xml</include>  
                    <include>**/*.properties</include>  
                </includes>  
            </resource>  
            <!-- 结合com.alibaba.dubbo.container.Main -->  
            <!-- 如果要用dubbo提供的main方法启动,则会默认读取sping.xml配置  -->  
            <resource>  
                <targetPath>${project.build.directory}/classes/META-INF/spring</targetPath>  
                <directory>src/main/resources/spring</directory>  
                <filtering>true</filtering>  
                <includes>  
                    <include>spring-context.xml</include>  
                </includes>  
            </resource>  
        </resources>  
          
        <pluginManagement>  
            <plugins>  
                <!-- 解决Maven插件在Eclipse内执行了一系列的生命周期引起冲突 -->  
                <plugin>  
                    <groupId>org.eclipse.m2e</groupId>  
                    <artifactId>lifecycle-mapping</artifactId>  
                    <version>1.0.0</version>  
                    <configuration>  
                        <lifecycleMappingMetadata>  
                            <pluginExecutions>  
                                <pluginExecution>  
                                    <pluginExecutionFilter>  
                                        <groupId>org.apache.maven.plugins</groupId>  
                                        <artifactId>maven-dependency-plugin</artifactId>  
                                        <versionRange>[2.0,)</versionRange>  
                                        <goals>  
                                            <goal>copy-dependencies</goal>  
                                        </goals>  
                                    </pluginExecutionFilter>  
                                    <action>  
                                        <ignore />  
                                    </action>  
                                </pluginExecution>  
                            </pluginExecutions>  
                        </lifecycleMappingMetadata>  
                    </configuration>  
                </plugin>  
            </plugins>  
        </pluginManagement>  
        <plugins>  
            <!-- 打包jar文件时,配置manifest文件,加入lib包的jar依赖 -->  
            <plugin>  
                <groupId>org.apache.maven.plugins</groupId>  
                <artifactId>maven-jar-plugin</artifactId>  
                <configuration>  
                    <classesDirectory>target/classes/</classesDirectory>  
                    <archive>  
                        <manifest>  
                            <mainClass>com.alibaba.dubbo.container.Main</mainClass>  
                            <!-- 打包时 MANIFEST.MF文件不记录的时间戳版本 -->  
                            <useUniqueVersions>false</useUniqueVersions>  
                            <addClasspath>true</addClasspath>  
                            <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>  
                                <!-- 这个jar包所依赖的jar包的存放路径 -->  
                                ${project.build.directory}/lib  
                            </outputDirectory>  
                        </configuration>  
                    </execution>  
                </executions>  
            </plugin>  
        </plugins>  
  
    </build>