当 AWS CodeBuild 从https://repo1.maven.org/maven2加载 maven 存储库时,构建时间大约为 60 秒(这是下载 Jars、构建和运行测试的时间)。
但是在更新 maven 存储库以从 AWS CodeArtifact 服务加载之后(即我在 AWS CodeArtifact 中创建了一个存储库以连接到 Maven 中央存储库),构建时间一直在 200 秒以上。
现在构建时间是否应该不短,因为一个 AWS 服务 (AWS CodeBuild) 正在与同一区域中的另一个 AWS 服务 (AWS CodeArtifact) 进行通信。所以他们会使用 AWS 网络吗?
有人可以分享一些关于增加构建时间的意见吗?
更新:在下面添加 Maven 依赖项:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<apache-commons.version>2.6</apache-commons.version>
<java.version>11</java.version>
<thymeleaf.version>3.0.11.RELEASE</thymeleaf.version>
<thymeleaf-layout-dialect.version>2.4.1</thymeleaf-layout-dialect.version>
<thymeleaf-extras-java8time.version>3.0.3.RELEASE</thymeleaf-extras-java8time.version>
<mybatis-starter.version>2.1.1</mybatis-starter.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>${mybatis-starter.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-oauth2-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth.boot</groupId>
<artifactId>spring-security-oauth2-autoconfigure</artifactId>
<version>2.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-resource-server</artifactId>
</dependency>
<!-- AWS -->
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>s3</artifactId>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>apache-client</artifactId>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>netty-nio-client</artifactId>
</dependency>
<dependency>
<artifactId>aws-java-sdk-s3</artifactId>
<groupId>com.amazonaws</groupId>
</dependency>
<!-- End of AWS -->
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-json -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-json</artifactId>
</dependency>
<dependency>
<groupId>nz.net.ultraq.thymeleaf</groupId>
<artifactId>thymeleaf-layout-dialect</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>19.3.0.0</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${apache-commons.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter-test</artifactId>
<version>${mybatis-starter.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.10.42</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-bom</artifactId>
<version>1.11.700</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
下载依赖项时的示例 CodeBuild 日志:
[INFO] Scanning for projects...
Downloading from codeartifact: https://<domain>.d.codeartifact.<region>.amazonaws.com/maven/maven/software/amazon/awssdk/bom/2.9.16/bom-2.9.16.pom
Progress (1): 4.1/47 kB
Progress (1): 8.2/47 kB
Progress (1): 12/47 kB
Progress (1): 16/47 kB
Progress (1): 20/47 kB
Progress (1): 25/47 kB
Progress (1): 29/47 kB
Progress (1): 33/47 kB
Progress (1): 35/47 kB
Progress (1): 39/47 kB
Progress (1): 43/47 kB
Progress (1): 47 kB
Downloaded from codeartifact: https://<domain>.d.codeartifact.<region>.amazonaws.com/maven/maven/software/amazon/awssdk/bom/2.9.16/bom-2.9.16.pom (47 kB at 46 kB/s)
Downloading from codeartifact: https://<domain>.d.codeartifact.<region>.amazonaws.com/maven/maven/software/amazon/awssdk/aws-sdk-java-pom/2.9.16/aws-sdk-java-pom-2.9.16.pom
Progress (1): 4.1/57 kB
Progress (1): 8.2/57 kB
Progress (1): 12/57 kB
Progress (1): 16/57 kB
Progress (1): 20/57 kB
Progress (1): 25/57 kB
Progress (1): 29/57 kB
Progress (1): 33/57 kB
Progress (1): 37/57 kB
Progress (1): 41/57 kB
Progress (1): 44/57 kB
Progress (1): 48/57 kB
Progress (1): 52/57 kB
Progress (1): 56/57 kB
Progress (1): 57 kB
Downloaded from codeartifact: https://<domain>.d.codeartifact.<region>.amazonaws.com/maven/maven/software/amazon/awssdk/aws-sdk-java-pom/2.9.16/aws-sdk-java-pom-2.9.16.pom (57 kB at 118 kB/s)
Downloading from codeartifact: https://<domain>.d.codeartifact.<region>.amazonaws.com/maven/maven/com/amazonaws/aws-java-sdk-bom/1.11.657/aws-java-sdk-bom-1.11.657.pom
Progress (1): 4.1/41 kB
Progress (1): 8.2/41 kB
Progress (1): 12/41 kB
Progress (1): 16/41 kB
Progress (1): 20/41 kB
Progress (1): 25/41 kB
Progress (1): 29/41 kB
Progress (1): 33/41 kB
Progress (1): 35/41 kB
Progress (1): 39/41 kB
Progress (1): 41 kB