创建第一个微服务

以惠缴税为例创建第一个微服务

1、maven 配置settings.xml

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository>E:/software_installer/apache-maven-3.6.1/repository</localRepository>
  <proxies>
  </proxies>
  <servers>
    <server>
      <id>nexus-release</id>
      <username>admin</username>
      <password>winchain@1</password>
    </server>
    <server>
      <id>nexus-snapshots</id>
      <username>admin</username>
      <password>winchain@1</password>
    </server>
    </servers>
  <mirrors>
    <mirror>
        <id>nexus</id>
        <mirrorOf>*</mirrorOf>
        <url>http://39.108.117.72:8000/repository/maven-public/</url>
    </mirror>

  </mirrors>

  <profiles>
    <profile>
      <id>jdk-1.8</id>

      <activation>
        <jdk>1.8</jdk>
      </activation>

      <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
      </properties>


      <repositories>
          <repository>
              <id>nexus-release</id>
              <name>release</name>
              <url>http://39.108.117.72:8000/repository/maven-public/</url>
              <releases>
                  <enabled>true</enabled>
              </releases>
              <snapshots>
                  <enabled>true</enabled>
              </snapshots>
          </repository>

          <repository>
              <id>nexus-snapshots</id>
              <name>snapshots</name>
              <url>http://39.108.117.72:8000/repository/maven-public/</url>
              <releases>
                  <enabled>true</enabled>
              </releases>
              <snapshots>
                  <enabled>true</enabled>
              </snapshots>
          </repository>
      </repositories>
    </profile>
  </profiles>
</settings>

2、配置maven-artche-type

在maven repository 目录下面新增配置文件archetype-catalog.xml 12.png 内容如下

<?xml version="1.0" encoding="UTF-8"?>
<archetype-catalog xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-catalog/1.0.0 http://maven.apache.org/xsd/archetype-catalog-1.0.0.xsd"
    xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-catalog/1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <archetypes>
    <archetype>
      <groupId>com.atlassian.maven.archetypes</groupId>
      <artifactId>confluence-plugin-archetype</artifactId>
      <version>16</version>
      <description>confluence-plugin-archetype</description>
    </archetype>
    <archetype>
      <groupId>com.shell.htax</groupId>
      <artifactId>maven-template-archetype</artifactId>
      <version>1.0.0-SNAPSHOT</version>
      <description>Demo project for Spring Boot</description>
    </archetype>
    <archetype>
      <groupId>org.apache.maven.archetypes</groupId>
      <artifactId>maven-archetype-quickstart</artifactId>
      <version>1.1</version>
      <description>quickstart</description>
    </archetype>
    <archetype>
      <groupId>org.apache.maven.archetypes</groupId>
      <artifactId>maven-archetype-webapp</artifactId>
      <version>1.0</version>
      <description>webapp</description>
    </archetype>
    <archetype>
      <groupId>org.apache.maven.archetypes</groupId>
      <artifactId>maven-archetype-webapp</artifactId>
      <version>1.4</version>
      <description>webapp</description>
    </archetype>
  </archetypes>
</archetype-catalog>

3、idea创建项目

6.png

7.png

8.png

9.png

10.png

Finish之后自动生成项目目录以及相关文件

11.png

4、运行

13.png

1、运行之前先修改包名,将template修改成自己的业务包名

2、修改bootstrap.properties 里面的application.name 和context-path

3、修改mavenTemplateApplication为自己的业务名称

4、修改pom.xml

mainClass 修改成自己的mainClass 14.png

5、run main class

6、运行可能不成功,需要先启动eureka和config,再启动当前服务

results matching ""

    No results matching ""