展开
拓展 关闭
订阅号推广码
GitHub
视频
公告栏 关闭

security + cloud模板

前言

部署

  • 当前项目为cloud + security案例模板,要部署cloud项目,将每个模块打成jar包上传到服务器,之后打成镜像
  • 打成镜像后启动容器报错:no main manifest attribute, in /app.jar
  • 参考
# 父工程
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-site-plugin</artifactId>
        <configuration>
          <locales>en,fr</locales>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <version>2.2.2.RELEASE</version>
        <configuration>
          <fork>true</fork>
          <addResources>true</addResources>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
# 要打包的子模块
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <includeSystemScope>true</includeSystemScope>
                </configuration>
            </plugin>
        </plugins>
    </build>
  • 为了在其他服务器上也能运行,yml配置的ip需改为本地
server:
  port: 8091

spring:
  cloud:
    nacos:
      discovery:
        server-addr: localhost:8848
  application:
    name: blog-resource
  datasource:
    dynamic:
      primary: master
      strict: false
      datasource:
        master:
          url: jdbc:mysql://localhost:3306/db_resource?useUnicode=true&characterEncoding=UTF-8
          username: root
          password: 123456
          driver-class-name: com.mysql.cj.jdbc.Driver
        slave_1:
          url: jdbc:mysql://localhost:3306/db_auth?useUnicode=true&characterEncoding=UTF-8
          username: root
          password: 123456
          driver-class-name: com.mysql.cj.jdbc.Driver

mybatis:
  configuration:
    map-underscore-to-camel-case: true

logging:
  level:
    com:
      blog:
        resource: debug
  • 启动容器后,访问容器的接口显示连接超时,这是因为容器对应的端口,宿主机服务器没有对外开放;需开放端口或关闭防火墙

posted @ 2021-12-26 23:23  DogLeftover  阅读(11)  评论(0编辑  收藏  举报