欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

SpringCloud -创建统一的依赖管理

程序员文章站 2022-03-07 10:37:00
场景 Spring Cloud 为开发者提供了在分布式系统(配置管理,服务发现,熔断,路由,微代理,控制总线,一次性 Token,全居琐,Leader 选举,分布式 Session,集群状态)中快速构建的工具,使用 Spring Cloud 的开发者可以快速的启动服务或构建应用、同时能够快速和云平台 ......

场景

spring cloud 为开发者提供了在分布式系统(配置管理,服务发现,熔断,路由,微代理,控制总线,一次性 token,全居琐,leader 选举,分布式 session,集群状态)中快速构建的工具,使用 spring cloud 的开发者可以快速的启动服务或构建应用、同时能够快速和云平台资源进行对接。

注:

博客:

关注公众号
霸道的程序猿
获取编程相关电子书、教程推送与免费下载。

实现

在目录下新建一个目录hello-spring-cloud ,然后使用idea打开这个目录。

SpringCloud -创建统一的依赖管理

这个文件夹是用来放所有工程的,所以在idea上右击目录继续新建目录。

SpringCloud -创建统一的依赖管理

为统一的依赖管理项目取名字。

SpringCloud -创建统一的依赖管理

SpringCloud -创建统一的依赖管理

新建完成后再新建file--pom.xml

SpringCloud -创建统一的依赖管理

 

 

SpringCloud -创建统一的依赖管理

复制如下代码:

<?xml version="1.0" encoding="utf-8"?>
<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/xsd/maven-4.0.0.xsd">
    <modelversion>4.0.0</modelversion>

    <parent>
        <groupid>org.springframework.boot</groupid>
        <artifactid>spring-boot-starter-parent</artifactid>
        <version>2.0.3.release</version>
    </parent>

    <groupid>com.badao</groupid>
    <artifactid>hello-spring-cloud-dependencies</artifactid>
    <version>1.0.0-snapshot</version>
    <packaging>pom</packaging>

    <name>hello-spring-cloud-dependencies</name>
    <url>https://blog.csdn.net/badao_liumang_qizhi</url>
    <inceptionyear>2019-now</inceptionyear>

    <properties>
        <!-- environment settings -->
        <java.version>1.8</java.version>
        <project.build.sourceencoding>utf-8</project.build.sourceencoding>
        <project.reporting.outputencoding>utf-8</project.reporting.outputencoding>

        <!-- spring settings -->
        <spring-cloud.version>finchley.rc1</spring-cloud.version>
    </properties>

    <dependencymanagement>
        <dependencies>
            <dependency>
                <groupid>org.springframework.cloud</groupid>
                <artifactid>spring-cloud-dependencies</artifactid>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencymanagement>

    <build>
        <plugins>
            <!-- compiler 插件, 设定 jdk 版本 -->
            <plugin>
                <groupid>org.apache.maven.plugins</groupid>
                <artifactid>maven-compiler-plugin</artifactid>
                <configuration>
                    <showwarnings>true</showwarnings>
                </configuration>
            </plugin>

            <!-- 打包 jar 文件时,配置 manifest 文件,加入 lib 包的 jar 依赖 -->
            <plugin>
                <groupid>org.apache.maven.plugins</groupid>
                <artifactid>maven-jar-plugin</artifactid>
                <configuration>
                    <archive>
                        <addmavendescriptor>false</addmavendescriptor>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <configuration>
                            <archive>
                                <manifest>
                                    <!-- add directory entries -->
                                    <adddefaultimplementationentries>true</adddefaultimplementationentries>
                                    <adddefaultspecificationentries>true</adddefaultspecificationentries>
                                    <addclasspath>true</addclasspath>
                                </manifest>
                            </archive>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- resource -->
            <plugin>
                <groupid>org.apache.maven.plugins</groupid>
                <artifactid>maven-resources-plugin</artifactid>
            </plugin>

            <!-- install -->
            <plugin>
                <groupid>org.apache.maven.plugins</groupid>
                <artifactid>maven-install-plugin</artifactid>
            </plugin>

            <!-- clean -->
            <plugin>
                <groupid>org.apache.maven.plugins</groupid>
                <artifactid>maven-clean-plugin</artifactid>
            </plugin>

            <!-- ant -->
            <plugin>
                <groupid>org.apache.maven.plugins</groupid>
                <artifactid>maven-antrun-plugin</artifactid>
            </plugin>

            <!-- dependency -->
            <plugin>
                <groupid>org.apache.maven.plugins</groupid>
                <artifactid>maven-dependency-plugin</artifactid>
            </plugin>
        </plugins>

        <pluginmanagement>
            <plugins>
                <!-- java document generate -->
                <plugin>
                    <groupid>org.apache.maven.plugins</groupid>
                    <artifactid>maven-javadoc-plugin</artifactid>
                    <executions>
                        <execution>
                            <phase>prepare-package</phase>
                            <goals>
                                <goal>jar</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>

                <!-- yui compressor (css/js压缩) -->
                <plugin>
                    <groupid>net.alchim31.maven</groupid>
                    <artifactid>yuicompressor-maven-plugin</artifactid>
                    <version>1.5.1</version>
                    <executions>
                        <execution>
                            <phase>prepare-package</phase>
                            <goals>
                                <goal>compress</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <encoding>utf-8</encoding>
                        <jswarn>false</jswarn>
                        <nosuffix>true</nosuffix>
                        <linebreakpos>30000</linebreakpos>
                        <force>true</force>
                        <includes>
                            <include>**/*.js</include>
                            <include>**/*.css</include>
                        </includes>
                        <excludes>
                            <exclude>**/*.min.js</exclude>
                            <exclude>**/*.min.css</exclude>
                        </excludes>
                    </configuration>
                </plugin>
            </plugins>
        </pluginmanagement>

        <!-- 资源文件配置 -->
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <excludes>
                    <exclude>**/*.java</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>
    </build>

    <repositories>
        <repository>
            <id>aliyun-repos</id>
            <name>aliyun repository</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>

        <repository>
            <id>sonatype-repos</id>
            <name>sonatype repository</name>
            <url>https://oss.sonatype.org/content/groups/public</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>sonatype-repos-s</id>
            <name>sonatype repository</name>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
            <releases>
                <enabled>false</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>

        <repository>
            <id>spring-snapshots</id>
            <name>spring snapshots</name>
            <url>https://repo.spring.io/snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>spring-milestones</id>
            <name>spring milestones</name>
            <url>https://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

    <pluginrepositories>
        <pluginrepository>
            <id>aliyun-repos</id>
            <name>aliyun repository</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginrepository>
    </pluginrepositories>
</project>

 

然后将pom.xml添加到托管

SpringCloud -创建统一的依赖管理

 

 

SpringCloud -创建统一的依赖管理