0

I am using maven 3.6 in Ubuntu. My 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>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.6.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.techprimers.serverless</groupId>
    <artifactId>spring-cloud-function-example</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>spring-cloud-function-example</name>
    <description>Demo project for Spring Boot with Spring  Cloud Function</description>

    <properties>
        <java.version>1.8</java.version>
        <spring-cloud.version>Greenwich.SR2</spring-cloud.version>
        <wrapper.version>1.0.3.BUILD-SNAPSHOT</wrapper.version>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-function-adapter-aws</artifactId>
            <version>3.0.2.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-lambda-java-core</artifactId>
            <version>1.2.0</version>
        </dependency>

        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-lambda-java-events</artifactId>
            <version>2.2.2</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Greenwich.SR2</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>org.springframework.boot.experimental</groupId>
                        <artifactId>spring-boot-thin-layout</artifactId>
                        <version>1.0.10.RELEASE</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <configuration>
                    <createDependencyReducedPom>false</createDependencyReducedPom>
                    <shadedArtifactAttached>true</shadedArtifactAttached>
                    <shadedClassifierName>aws</shadedClassifierName>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

I get error as:-

Error:(7,8) java: cannot access org.springframework.cloud.function.context.AbstractSpringFunctionAdapterInitializer

What is wrong here? How do I fix it?

masiboo
  • 4,537
  • 9
  • 75
  • 136
  • https://search.maven.org/search?q=g:org.springframework.cloud https://search.maven.org/search?q=a:spring-cloud-dependencies perhaps? (Spring Cloud Dependencies would be my guess) – JGFMK Jun 24 '20 at 11:02
  • First I would suggest to upgrade to 3.0.8 of spring-cloud-function. Also, there is not enough information in your question to even begin diagnosing the issue. Perhaps stack trace? Also, there were significant improvements in functions AWS so consider following this quick start - https://docs.spring.io/spring-cloud-function/docs/3.0.8.RELEASE/reference/html/aws.html#_aws_lambda – Oleg Zhurakousky Jun 24 '20 at 12:07

1 Answers1

0

I tried various older and newer versions of spring-cloud-function-adapter-aws. I managed to compile by the following version.

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-function-adapter-aws</artifactId>
        <version>1.0.1.RELEASE</version>
    </dependency>
masiboo
  • 4,537
  • 9
  • 75
  • 136