我在执行与AWS的持续集成的工具lambda函数。的CodeSource,CodeBuild CodePipeLine。
设立毕竟,当我测试的拉姆达结果
{
"errorMessage": "Class not found: com.ad.client.App",
"errorType": "java.lang.ClassNotFoundException"
}
Class not found: com.ad.client.App: java.lang.ClassNotFoundException
java.lang.ClassNotFoundException: com.ad.client.App
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
管道的所有阶段都成功(资料来源,构建,部署)
如果直接在拉姆达罐子安慰结果的负荷是正确的我审查日志生成的,发现这个:
[Container] 2019/06/13 13:09:38 Running command echo THE PATH WORK IS !!!
THE PATH WORK IS !!!
[Container] 2019/06/13 13:09:38 Running command pwd
/codebuild/output/src748698927/src
[Container] 2019/06/13 13:09:38 Running command echo The list of file is !!
The list of file is !!
[Container] 2019/06/13 13:09:38 Running command ls
Readme.md
buildspec.yml
dependency-reduced-pom.xml
ftc-client.iml
outputtemplate.yaml
pom.xml
src
target
template.yaml
[Container] 2019/06/13 13:09:38 Running command echo CODE BUILD SRC DIRECTORY
CODE BUILD SRC DIRECTORY
[Container] 2019/06/13 13:09:38 Running command echo $CODEBUILD_SRC_DIR
/codebuild/output/src748698927/src
INFO] skip non existing resourceDirectory /codebuild/output/src748698927/src/src/main/resources
在一些代码部分告诉我,路径SRC是重复的,我不知道是否有一些与问题相关的
我的配置文件是:
template.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Ftc-client
Resources:
FtcClientFunction:
Type: AWS::Serverless::Function
Properties:
Handler: com.ad.client.App::handleRequest
Runtime: java8
CodeUri: ./
Events:
MyFtcClientApi:
Type: Api
Properties:
Path: /client
Method: GET
buildspec.yml
version: 0.2
phases:
install:
runtime-versions:
java: openjdk8
build:
commands:
- echo Build started on `date`
- mvn test
- export BUCKET=my-bucket-for-test
- aws cloudformation package --template-file template.yaml --s3-bucket $BUCKET --output-template-file outputtemplate.yaml
finally:
- echo THE PATH WORK IS !!!
- pwd
- echo The list of file is !!
- ls
- echo CODE BUILD SRC DIRECTORY
- echo $CODEBUILD_SRC_DIR
post_build:
commands:
- echo Build completed on `date`
- mvn package
artifacts:
files:
- target/ftc-client-1.0-SNAPSHOT.jar
- template.yaml
- outputtemplate.yaml
discard-paths: yes
The source code structure is :
/fclient/src/main/java/com/ad/App.java
/tclient/buildspec.yml
/fclient/pom.xml
/fclient/template.yaml
我想使这个,但与Java:https://docs.aws.amazon.com/lambda/latest/dg/build-pipeline.html
感谢大家谁可以给我一个提示
这是解决方案 - 这是必要的解压的jar在我的代码根:
version: 0.2
phases:
install:
runtime-versions:
java: openjdk8
pre_build:
commands:
- echo Test started on `date`
- mvn clean compile test
build:
commands:
- echo Build started on `date`
- export BUCKET=my-bucket-for-test
- mvn package shade:shade
- mv target/ftc-client-1.0-SNAPSHOT.jar
- unzip ftc-client-1.0-SNAPSHOT.jar
- rm -rf target tst src buildspec.yml pom.xml ftc-client-1.0-SNAPSHOT.jar
- aws cloudformation package --template-file template.yaml --s3-bucket $BUCKET --output-template-file outputtemplate.yaml
post_build:
commands:
- echo Build completed on `date` !!!
artifacts:
files:
- target/ftc-client-1.0-SNAPSHOT.jar
- template.yaml
- outputtemplate.yaml
https://docs.aws.amazon.com/codebuild/latest/userguide/build-spec-ref.html
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句