运行Spring应用程序问题

时间:2019-01-29 15:20:11

标签: java spring maven spring-boot

我有一个正在处理的项目的微服务体系结构,最近我正在使用Eclipse STS,并且每当我运行我的一个应用微服务时我从上下文菜单中使用run as spring boot应用程序 >

昨天我想试验Visual Studio Code,以便运行我的应用程序,我尝试使用.\mvnwmvn spring-boot:run使用powershell终端,但是很不幸,在我的一项服务中,它运行不正常,并且我有以下例外情况

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 

    at demo.ClientApplication.main(ClientApplication.java:70)

所需项目具有以下pom.xml

<?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>

    <groupId>mds.group</groupId>
    <artifactId>MDS-Facture-client</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>MDS-Facture-client</name>
    <description>Client Web de la facturation</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.6.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
        <spring-cloud.version>Dalston.SR2</spring-cloud.version>
        <thymeleaf.version>3.0.6.RELEASE</thymeleaf.version>
        <thymeleaf-layout-dialect.version>2.2.1</thymeleaf-layout-dialect.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>net.sf.jasperreports</groupId>
            <artifactId>jasperreports</artifactId>
            <version>6.4.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-oauth2</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-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>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jsr310</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-feign</artifactId>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
     <dependency>
      <groupId>com.mds</groupId>
      <artifactId>data-shema</artifactId>
      <version>0.0.1-SNAPSHOT</version>
     </dependency>
     <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
     </dependency>
    </dependencies>

    <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>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

我应该怎么做才能从vs-code作为maven命令运行以解决此问题? (以另一种方式重现STS用来成功启动我的应用程序的生成的maven命令)

在ugur评论之后,我尝试执行mvn clean编译,但出现以下编译错误

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/notification/NotificationRestMediator.java:[10,27] package com.mds.shema.Feign does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/notification/NotificationRestMediator.java:[11,25] package com.mds.shema.dto does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/notification/NotificationRestMediator.java:[19,17] cannot find symbol
  symbol:   class NotifFeignClient
  location: class demo.notification.NotificationRestMediator
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/notification/NotificationRestMediator.java:[22,14] cannot find symbol
  symbol:   class NotificationDTO
  location: class demo.notification.NotificationRestMediator
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/produit/ProduitRestMediatorController.java:[15,27] package com.mds.shema.Feign does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/produit/ProduitRestMediatorController.java:[16,25] package com.mds.shema.dto does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/produit/ProduitRestMediatorController.java:[25,17] cannot find symbol
  symbol:   class ProductFeignClient
  location: class demo.produit.ProduitRestMediatorController
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/produit/ProduitRestMediatorController.java:[34,43] cannot find symbol
  symbol:   class ProduitEditDTO
  location: class demo.produit.ProduitRestMediatorController
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/produit/ProduitRestMediatorController.java:[42,14] cannot find symbol
  symbol:   class ProduitEditDTO
  location: class demo.produit.ProduitRestMediatorController
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/produit/ProduitRestMediatorController.java:[48,41] cannot find symbol
  symbol:   class ProduitEditDTO
  location: class demo.produit.ProduitRestMediatorController
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/LandingController.java:[17,27] package com.mds.shema.Feign does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/LandingController.java:[18,27] package com.mds.shema.Feign does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/LandingController.java:[19,27] package com.mds.shema.Feign does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/LandingController.java:[20,25] package com.mds.shema.dto does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/LandingController.java:[21,25] package com.mds.shema.dto does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/LandingController.java:[35,17] cannot find symbol
  symbol:   class AppClientFeign
  location: class demo.LandingController
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/LandingController.java:[38,17] cannot find symbol
  symbol:   class UserClientFeign
  location: class demo.LandingController
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/company/CompanyController.java:[12,25] package com.mds.shema.dto does
not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/company/CompanyController.java:[20,80] cannot find symbol
  symbol:   class CompanySettingQuickFormDTO
  location: class demo.company.CompanyController
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/company/CompanyController.java:[28,42] cannot find symbol
  symbol:   class CompanySettingQuickFormDTO
  location: class demo.company.CompanyController
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/refclient/RefClientMediatorController.java:[16,27] package com.mds.shema.Feign does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/refclient/RefClientMediatorController.java:[17,25] package com.mds.shema.dto does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/refclient/RefClientMediatorController.java:[33,17] cannot find symbol
  symbol:   class RefClientFeign
  location: class demo.refclient.RefClientMediatorController
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/refclient/RefClientMediatorController.java:[36,60] cannot find symbol
  symbol:   class AddClientDTO
  location: class demo.refclient.RefClientMediatorController
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/refclient/RefClientMediatorController.java:[56,61] cannot find symbol
  symbol:   class AddClientDTO
  location: class demo.refclient.RefClientMediatorController
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/printer/PrintController.java:[20,26] package com.mds.shema.json does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/printer/PrintController.java:[74,64] cannot find symbol
  symbol:   class ClientJsonDto
  location: class demo.printer.PrintController
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/ClientApplication.java:[21,21] package com.mds.shema does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/refclient/RefClientMediatorRestController.java:[12,27] package com.mds.shema.Feign does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/refclient/RefClientMediatorRestController.java:[13,25] package com.mds.shema.dto does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/refclient/RefClientMediatorRestController.java:[22,17] cannot find symbol
  symbol:   class RefClientFeign
  location: class demo.refclient.RefClientMediatorRestController
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/refclient/RefClientMediatorRestController.java:[25,29] cannot find symbol
  symbol:   class ClientDTO
  location: class demo.refclient.RefClientMediatorRestController
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/ClientApplication.java:[54,44] cannot find symbol
  symbol: class DemoApplication
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/ClientApplication.java:[56,64] cannot find symbol
  symbol: class DemoApplication
[INFO] 34 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  10.912 s
[INFO] Finished at: 2019-01-29T16:56:37+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project MDS-Facture-client: Compilation failure: Compilation failure:
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/notification/NotificationRestMediator.java:[10,27] package com.mds.shema.Feign does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/notification/NotificationRestMediator.java:[11,25] package com.mds.shema.dto does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/notification/NotificationRestMediator.java:[19,17] cannot find symbol
[ERROR]   symbol:   class NotifFeignClient
[ERROR]   location: class demo.notification.NotificationRestMediator
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/notification/NotificationRestMediator.java:[22,14] cannot find symbol
[ERROR]   symbol:   class NotificationDTO
[ERROR]   location: class demo.notification.NotificationRestMediator
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/produit/ProduitRestMediatorController.java:[15,27] package com.mds.shema.Feign does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/produit/ProduitRestMediatorController.java:[16,25] package com.mds.shema.dto does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/produit/ProduitRestMediatorController.java:[25,17] cannot find symbol
[ERROR]   symbol:   class ProductFeignClient
[ERROR]   location: class demo.produit.ProduitRestMediatorController
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/produit/ProduitRestMediatorController.java:[34,43] cannot find symbol
[ERROR]   symbol:   class ProduitEditDTO
[ERROR]   location: class demo.produit.ProduitRestMediatorController
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/produit/ProduitRestMediatorController.java:[42,14] cannot find symbol
[ERROR]   symbol:   class ProduitEditDTO
[ERROR]   location: class demo.produit.ProduitRestMediatorController
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/produit/ProduitRestMediatorController.java:[48,41] cannot find symbol
[ERROR]   symbol:   class ProduitEditDTO
[ERROR]   location: class demo.produit.ProduitRestMediatorController
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/LandingController.java:[17,27] package com.mds.shema.Feign does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/LandingController.java:[18,27] package com.mds.shema.Feign does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/LandingController.java:[19,27] package com.mds.shema.Feign does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/LandingController.java:[20,25] package com.mds.shema.dto does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/LandingController.java:[21,25] package com.mds.shema.dto does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/LandingController.java:[35,17] cannot find symbol
[ERROR]   symbol:   class AppClientFeign
[ERROR]   location: class demo.LandingController
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/LandingController.java:[38,17] cannot find symbol
[ERROR]   symbol:   class UserClientFeign
[ERROR]   location: class demo.LandingController
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/company/CompanyController.java:[12,25] package com.mds.shema.dto does
not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/company/CompanyController.java:[20,80] cannot find symbol
[ERROR]   symbol:   class CompanySettingQuickFormDTO
[ERROR]   location: class demo.company.CompanyController
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/company/CompanyController.java:[28,42] cannot find symbol
[ERROR]   symbol:   class CompanySettingQuickFormDTO
[ERROR]   location: class demo.company.CompanyController
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/refclient/RefClientMediatorController.java:[16,27] package com.mds.shema.Feign does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/refclient/RefClientMediatorController.java:[17,25] package com.mds.shema.dto does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/refclient/RefClientMediatorController.java:[33,17] cannot find symbol
[ERROR]   symbol:   class RefClientFeign
[ERROR]   location: class demo.refclient.RefClientMediatorController
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/refclient/RefClientMediatorController.java:[36,60] cannot find symbol
[ERROR]   symbol:   class AddClientDTO
[ERROR]   location: class demo.refclient.RefClientMediatorController
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/refclient/RefClientMediatorController.java:[56,61] cannot find symbol
[ERROR]   symbol:   class AddClientDTO
[ERROR]   location: class demo.refclient.RefClientMediatorController
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/printer/PrintController.java:[20,26] package com.mds.shema.json does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/printer/PrintController.java:[74,64] cannot find symbol
[ERROR]   symbol:   class ClientJsonDto
[ERROR]   location: class demo.printer.PrintController
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/ClientApplication.java:[21,21] package com.mds.shema does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/refclient/RefClientMediatorRestController.java:[12,27] package com.mds.shema.Feign does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/refclient/RefClientMediatorRestController.java:[13,25] package com.mds.shema.dto does not exist
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/refclient/RefClientMediatorRestController.java:[22,17] cannot find symbol
[ERROR]   symbol:   class RefClientFeign
[ERROR]   location: class demo.refclient.RefClientMediatorRestController
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/refclient/RefClientMediatorRestController.java:[25,29] cannot find symbol
[ERROR]   symbol:   class ClientDTO
[ERROR]   location: class demo.refclient.RefClientMediatorRestController
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/ClientApplication.java:[54,44] cannot find symbol
[ERROR]   symbol: class DemoApplication
[ERROR] /C:/Users/win 10/Documents/Google Drive/cloud server oauth2/clientFactureMS/src/main/java/demo/ClientApplication.java:[56,64] cannot find symbol
[ERROR]   symbol: class DemoApplication
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

似乎编译器无法识别我添加的data-shema依赖项 所以我要关闭这个线程,然后打开另一个如果我不能解决这个问题

1 个答案:

答案 0 :(得分:0)

我使用SharedCode项目在微服务之间共享我的伪客户端和dto,问题是在共享代码中,我在此版本中使用spring boot v 2.xx,我使用了feign依赖而没有具体化版本,因此spring使用了最新版本的feign与Spring Boot 2.xx兼容

由于我使用的是伪装版本,因此在设置伪装请求方法时,参数值不是必需的

但是由于我的SharedCode使用maven pom依赖关系链接到我的其他微服务,所以我犯了一个错误,使我的微服务在spring boot 1.5.6上进行,并添加了所有需要的扫描和类配置

这里出现错误,因为当spring扫描假客户端时,它将使用当前项目版本,其中假问题参数值对于困扰编译问题的任何请求签名都是必需的,而从未在单独的SharedCode项目编译中抛出