簡體   English   中英

無法解決錯誤:應用程序無法使用類路徑啟動:

[英]Unable to resolve the error: Application failed to start with classpath:

運行 java spring 啟動應用程序時出現以下錯誤。 要開始這個我 go 到我的應用程序。java 文件在主 package 並運行為 ZD52181878D3E9A22 應用程序。

Error:
Application failed to start with classpath: ...
36:45.59 [main] ERROR org.springframework.boot.SpringApplication - Application run failed. 
com.amazonaws.SdkClientException : Unable to find region via the region provider chain. Must provide an explicit region in the builder or setup environment to supply a region.

以下是 pom.xml 文件:

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <!-- we are extending from this project POM which means we get everything 
        that this pom has (inheritance) -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.0.RELEASE</version>
    </parent>

    <dependencies>
        <!-- base spring functionality -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
        </dependency>

        <!-- MySQL Connector -->
        <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.13</version>
        </dependency>

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- nekohtml dependency -->
        <dependency>
            <groupId>net.sourceforge.nekohtml</groupId>
            <artifactId>nekohtml</artifactId>
        </dependency>
        <!-- auto config for spring stuff -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- JPA Java Persistence API, interface for saving/fetching data -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <!-- Dev tools for no-restart, etc -->
        
        <!-- <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional>
        </dependency> -->
        
        <!-- Swagger Dependencies -->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.6.1</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.6.1</version>
        </dependency>
        <!-- Thymeleaf email dependency -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <!--Health Check -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <!--Admin -->
        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-starter-client</artifactId>
            <version>2.1.6</version>
        </dependency>
        <!--Security -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
        </dependency>
        <!-- LiquiBase -->
        <dependency>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-core</artifactId>
        </dependency>
        <!-- LiquiBase -->

        <dependency>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-maven-plugin</artifactId>
            <version>3.4.1</version>
        </dependency>
        
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk</artifactId>
            <version>1.11.600</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>
    </dependencies>

    <properties>
        <java.version>1.8</java.version>
    </properties>
    <build>
        <...>
        <plugins>
            <plugin>
                <groupId>external.atlassian.jgitflow</groupId>
                <artifactId>jgitflow-maven-plugin</artifactId>
                <version>1.0-m5.1</version>
                <configuration>
                    <!-- No Maven deploy. -->
                    <noDeploy>true</noDeploy>
                    <!-- No merge, we'll do manual by pull request -->
                    <noReleaseMerge>true</noReleaseMerge>
                    <!-- No merge, we'll do manual by pull request -->
                    <noFeatureMerge>true</noFeatureMerge>
                    <!-- Keep branch for manual pull request -->
                    <keepBranch>true</keepBranch>
                    <flowInitContext>
                        <masterBranchName>stage</masterBranchName>
                        <developBranchName>develop</developBranchName>
                        <featureBranchPrefix>feature-</featureBranchPrefix>
                        <releaseBranchPrefix>release-</releaseBranchPrefix>
                        <hotfixBranchPrefix>hotfix-</hotfixBranchPrefix>
                        <versionTagPrefix>version-</versionTagPrefix>
                    </flowInitContext>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>build-info</goal>
                        </goals>
                </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <!-- look online for options like specify directory -->
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <useSystemClassLoader>false</useSystemClassLoader>
                </configuration>
            </plugin>
            <!-- liquibase -->

            <plugin>
                <groupId>org.liquibase</groupId>
                <artifactId>liquibase-maven-plugin</artifactId>
                <version>3.4.1</version>
                <configuration>
                    <propertyFile>src/test/resources/liquibaseMaven.properties</propertyFile>
                </configuration>
                <!-- -->
                <dependencies>
                    <dependency>
                        <groupId>org.liquibase.ext</groupId>
                        <artifactId>liquibase-hibernate4</artifactId>
                        <version>3.5</version>
                    </dependency>
                    <dependency>
                        <groupId>org.springframework</groupId>
                        <artifactId>spring-beans</artifactId>
                        <version>4.1.7.RELEASE</version>
                    </dependency>
                    <dependency>
                        <groupId>org.springframework.data</groupId>
                        <artifactId>spring-data-jpa</artifactId>
                        <version>1.7.3.RELEASE</version>
                    </dependency>
                </dependencies>
                <!-- -->
            </plugin>
            <!-- liquibase -->

        </plugins>
    </build>

    <repositories>
        <repository>
            <id>spring-releases</id>
            <url>https://repo.spring.io/libs-release</url>
        </repository>
        <repository>
            <id>....</id>
            <name>AWS Release Repository</name>
            <url>s3://.../...</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>spring-releases</id>
            <url>https://repo.spring.io/libs-release</url>
        </pluginRepository>
    </pluginRepositories>
</project>

以下是 application.properties 文件:

spring.profiles.active=local

awsParameterStorePropertySource.enabled = true

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect

api.s3.accessKey=...
api.s3.secretKey=...

在進行故障排除時,以下是我嘗試過的事情:

  1. maven 清潔,maven 安裝,maven 構建
  2. 從您的計算機中刪除 .m2 文件檢查 settings.xml 文件重新安裝 .m2 文件並確保路徑正確。
  3. 卸載並重新安裝 eclipse
  4. 仔細檢查 AWS 密鑰
  5. 從您的計算機中完全刪除 repo 並重新克隆
  6. 檢查 AWS 中的區域,
  7. 檢查您的 AWS CLI 配置中的憑證是否匹配
  8. 在 S3 存儲桶中授予訪問權限

你們對這個錯誤有什么建議嗎?

我看到您正在嘗試在 application.properties 中定義您的信譽。 相反 - 嘗試根據此處的 AWS Java 開發指南設置您的密鑰:

使用憑據

我們在各種 AWS 服務指南中提供了許多 Spring 啟動示例。 這些示例應用程序通過將憑據放入此處名為憑據的文件中來處理憑據:C:\Users<yourUserName>.aws\credentials(或對於 Linux - ~/.aws/credentials)。

要了解如何編寫使用 AWS 服務的成功 Spring BOOT 應用程序,請參閱Amazon Simple Notification Service Guide中的此示例,該指南展示了如何開發具有 Sub/Pub 功能的 Spring BOOT 應用程序:

構建翻譯消息的發布和訂閱 web 應用程序

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM