当运行SAM构建时,我在依赖于项目中另一个本地模块的模块上得到一个依赖性错误。从mvn或IntelliJ我没有问题,但当我执行SAM构建,我得到了一个错误的notFound符号和类。
Build Failed
Error: JavaMavenWorkflow:MavenBuild - Maven Failed: [INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] backend [pom]
[INFO] Api [jar]
[INFO] Register [jar]
[INFO]
[INFO] ------------------------< com.backend:backend >-------------------------
[INFO] Building backend 0.0.1-SNAPSHOT [1/3]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.2.0:clean (default-clean) @ backend ---
[INFO]
[INFO] --- spring-boot-maven-plugin:3.0.6:repackage (repackage) @ backend ---
[INFO]
[INFO] --- maven-install-plugin:3.0.1:install (default-install) @ backend ---
[INFO] Installing /tmp/tmptflbmqgd/pom.xml to /home/laingard/.m2/repository/com/backend/backend/0.0.1-SNAPSHOT/backend-0.0.1-SNAPSHOT.pom
[INFO]
[INFO] --------------------------< com.backend:Api >---------------------------
[INFO] Building Api 0.0.1-SNAPSHOT [2/3]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.2.0:clean (default-clean) @ Api ---
[INFO] Deleting /tmp/tmptflbmqgd/Api/target
[INFO]
[INFO] --- maven-resources-plugin:3.3.1:resources (default-resources) @ Api ---
[INFO] Copying 0 resource from src/main/resources to target/classes
[INFO] skip non existing resourceDirectory /tmp/tmptflbmqgd/Api/config
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ Api ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 93 source files to /tmp/tmptflbmqgd/Api/target/classes
[INFO]
[INFO] --- maven-resources-plugin:3.3.1:testResources (default-testResources) @ Api ---
[INFO] skip non existing resourceDirectory /tmp/tmptflbmqgd/Api/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:testCompile (default-testCompile) @ Api ---
[INFO] Changes detected - recompiling the module!
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ Api ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- maven-jar-plugin:3.3.0:jar (default-jar) @ Api ---
[INFO] Building jar: /tmp/tmptflbmqgd/Api/target/Api-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] --- spring-boot-maven-plugin:3.0.6:repackage (repackage) @ Api ---
[INFO] Replacing main artifact with repackaged archive
[INFO]
[INFO] --- maven-install-plugin:3.0.1:install (default-install) @ Api ---
[INFO] Installing /tmp/tmptflbmqgd/Api/pom.xml to /home/laingard/.m2/repository/com/backend/Api/0.0.1-SNAPSHOT/Api-0.0.1-SNAPSHOT.pom
[INFO] Installing /tmp/tmptflbmqgd/Api/target/Api-0.0.1-SNAPSHOT.jar to /home/laingard/.m2/repository/com/backend/Api/0.0.1-SNAPSHOT/Api-0.0.1-SNAPSHOT.jar
[INFO]
[INFO] ------------------------< com.backend:Register >------------------------
[INFO] Building Register 0.0.1-SNAPSHOT [3/3]
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.2.0:clean (default-clean) @ Register ---
[INFO] Deleting /tmp/tmptflbmqgd/Register/target
[INFO]
[INFO] --- maven-resources-plugin:3.3.1:resources (default-resources) @ Register ---
[INFO] Copying 0 resource from src/main/resources to target/classes
[INFO] skip non existing resourceDirectory /tmp/tmptflbmqgd/Register/config
[INFO]
[INFO] --- maven-compiler-plugin:3.10.1:compile (default-compile) @ Register ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 9 source files to /tmp/tmptflbmqgd/Register/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /tmp/tmptflbmqgd/Register/src/main/java/com/careerwatch/register/service/RegisterServiceImpl.java:[3,34] package com.careerwatch.Api.entity does not exist
[ERROR] /tmp/tmptflbmqgd/Register/src/main/java/com/careerwatch/register/service/RegisterServiceImpl.java:[4,37] package com.careerwatch.Api.exception does not exist
[ERROR] /tmp/tmptflbmqgd/Register/src/main/java/com/careerwatch/register/service/RegisterServiceImpl.java:[5,38] package com.careerwatch.Api.repository does not exist
[ERROR] /tmp/tmptflbmqgd/Register/src/main/java/com/careerwatch/register/service/RegisterServiceImpl.java:[18,19] cannot find symbol
symbol: class UserRepository
location: class com.careerwatch.register.service.RegisterServiceImpl
[ERROR] /tmp/tmptflbmqgd/Register/src/main/java/com/careerwatch/register/jwt/JwtService.java:[3,34] package com.careerwatch.Api.entity does not exist
[ERROR] /tmp/tmptflbmqgd/Register/src/main/java/com/careerwatch/register/jwt/JwtService.java:[4,38] package com.careerwatch.Api.repository does not exist
[ERROR] /tmp/tmptflbmqgd/Register/src/main/java/com/careerwatch/register/mapper/RegisterDtoMapper.java:[3,34] package com.careerwatch.Api.entity does not exist
[ERROR] /tmp/tmptflbmqgd/Register/src/main/java/com/careerwatch/register/service/RegisterServiceImpl.java:[15,1] cannot find symbol
symbol: class UserRepository
location: class com.careerwatch.register.service.RegisterServiceImpl
[ERROR] /tmp/tmptflbmqgd/Register/src/main/java/com/careerwatch/register/mapper/RegisterDtoMapper.java:[13,12] cannot find symbol
symbol: class User
location: class com.careerwatch.register.mapper.RegisterDtoMapper
[ERROR] /tmp/tmptflbmqgd/Register/src/main/java/com/careerwatch/register/jwt/JwtService.java:[26,5] cannot find symbol
symbol: class UserRepository
location: class com.careerwatch.register.jwt.JwtService
[ERROR] /tmp/tmptflbmqgd/Register/src/main/java/com/careerwatch/register/jwt/JwtService.java:[34,33] cannot find symbol
symbol: class User
location: class com.careerwatch.register.jwt.JwtService
[ERROR] /tmp/tmptflbmqgd/Register/src/main/java/com/careerwatch/register/jwt/JwtService.java:[66,47] cannot find symbol
symbol: class User
location: class com.careerwatch.register.jwt.JwtService
[INFO] 12 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for backend 0.0.1-SNAPSHOT:
[INFO]
[INFO] backend ............................................ SUCCESS [ 0.565 s]
[INFO] Api ................................................ SUCCESS [ 3.314 s]
[INFO] Register ........................................... FAILURE [ 0.534 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.575 s
[INFO] Finished at: 2023-06-01T12:51:53-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project Register: Compilation failure: Compilation failure:
[ERROR] /tmp/tmptflbmqgd/Register/src/main/java/com/careerwatch/register/service/RegisterServiceImpl.java:[3,34] package com.careerwatch.Api.entity does not exist
[ERROR] /tmp/tmptflbmqgd/Register/src/main/java/com/careerwatch/register/service/RegisterServiceImpl.java:[4,37] package com.careerwatch.Api.exception does not exist
[ERROR] /tmp/tmptflbmqgd/Register/src/main/java/com/careerwatch/register/service/RegisterServiceImpl.java:[5,38] package com.careerwatch.Api.repository does not exist
[ERROR] /tmp/tmptflbmqgd/Register/src/main/java/com/careerwatch/register/service/RegisterServiceImpl.java:[18,19] cannot find symbol
[ERROR] symbol: class UserRepository
[ERROR] location: class com.careerwatch.register.service.RegisterServiceImpl
[ERROR] /tmp/tmptflbmqgd/Register/src/main/java/com/careerwatch/register/jwt/JwtService.java:[3,34] package com.careerwatch.Api.entity does not exist
[ERROR] /tmp/tmptflbmqgd/Register/src/main/java/com/careerwatch/register/jwt/JwtService.java:[4,38] package com.careerwatch.Api.repository does not exist
[ERROR] /tmp/tmptflbmqgd/Register/src/main/java/com/careerwatch/register/mapper/RegisterDtoMapper.java:[3,34] package com.careerwatch.Api.entity does not exist
[ERROR] /tmp/tmptflbmqgd/Register/src/main/java/com/careerwatch/register/service/RegisterServiceImpl.java:[15,1] cannot find symbol
[ERROR] symbol: class UserRepository
[ERROR] location: class com.careerwatch.register.service.RegisterServiceImpl
[ERROR] /tmp/tmptflbmqgd/Register/src/main/java/com/careerwatch/register/mapper/RegisterDtoMapper.java:[13,12] cannot find symbol
[ERROR] symbol: class User
[ERROR] location: class com.careerwatch.register.mapper.RegisterDtoMapper
[ERROR] /tmp/tmptflbmqgd/Register/src/main/java/com/careerwatch/register/jwt/JwtService.java:[26,5] cannot find symbol
[ERROR] symbol: class UserRepository
[ERROR] location: class com.careerwatch.register.jwt.JwtService
[ERROR] /tmp/tmptflbmqgd/Register/src/main/java/com/careerwatch/register/jwt/JwtService.java:[34,33] cannot find symbol
[ERROR] symbol: class User
[ERROR] location: class com.careerwatch.register.jwt.JwtService
[ERROR] /tmp/tmptflbmqgd/Register/src/main/java/com/careerwatch/register/jwt/JwtService.java:[66,47] cannot find symbol
[ERROR] symbol: class User
[ERROR] location: class com.careerwatch.register.jwt.JwtService
[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
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <args> -rf :Register
这是我的模板.yml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Globals:
Function:
Timeout: 30
Resources:
CareerWatchFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: .
Handler: com.careerwatch.Api.StreamLambdaHandler::handleRequest
Runtime: java17
AutoPublishAlias: production
SnapStart:
ApplyOn: PublishedVersions
Architectures:
- x86_64
MemorySize: 1024
Environment:
Variables:
POWERTOOLS_SERVICE_NAME: CareerWatchApi
DB_HOST: !Ref DBhost
DB_PORT: !Ref DBport
DB_NAME: !Ref DBname
DB_USERNAME: !Ref DBusername
DB_PASSWORD: !Ref DBpassword
Events:
HelloWorld:
Type: Api
Properties:
Path: /{proxy+}
Method: ANY
RegisterFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: .
Handler: com.careerwatch.register.RegisterLambdaHandler::handleRequest
Runtime: java17
AutoPublishAlias: production
SnapStart:
ApplyOn: PublishedVersions
Architectures:
- x86_64
MemorySize: 1024
Environment:
Variables:
POWERTOOLS_SERVICE_NAME: CareerWatchApi
DB_HOST: !Ref DBhost
DB_PORT: !Ref DBport
DB_NAME: !Ref DBname
DB_USERNAME: !Ref DBusername
DB_PASSWORD: !Ref DBpassword
SECRET_KEY: !Ref SecretKey
Events:
RegisterEndpoint:
Type: Api
Properties:
Path: /api/v1/register
Method: POST
Parameters:
DBhost:
Type: String
Default: ''
Description: Enter the DB host name or IP address
DBport:
Type: String
Default: ''
Description: Enter the DB port
DBname:
Type: String
Default: ''
Description: Enter the DB name
DBusername:
Type: String
Default: ''
Description: Enter the DB username
DBpassword:
Type: String
Default: ''
Description: Enter the DB password
SecretKey:
Type: String
Default: ''
Description: Enter the secret jwt key password
我做了mvn install
并检查了整个项目的结构,但是在maven中可以工作,但是在sam build中不行。
1条答案
按热度按时间kyks70gy1#
你在评论中说:
“我正在构建一个无服务器应用程序,在API网关中部署lambdas函数。
如果您对使用Java构建无服务器应用程序感兴趣,请查看PAM示例。此示例构建了一个完整的无服务器示例,该示例使用API Gateway、Lambda函数、Java SDK、使用Cognito登录用户的客户端应用程序等。
下面是概览图:
同样,本示例使用AWS CDK来支持各种资源。
这不使用SAM。
参见:
Create a photo asset management application that lets users manage photos using labels