04-05-2023 08:39 AM
Hello,
I created a spring boot application to create an out-of-process application using rest api.
But it failed to run because the missing of the bean NodesApi by displaying the following error message.
Consider defining a bean of type 'org.alfresco.core.handler.NodesApi' in your configuration.
I followed the documentation https://docs.alfresco.com/content-services/latest/develop/oop-ext-points/rest-api-java-wrapper/#list...
I initialized the NodesApi with the @Autowired Spring annotation and here is my code :
package com.arondor.alfrescooutofprocessrestapi; import org.alfresco.core.handler.NodesApi; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class AlfrescoOutOfProcessRestapiApplication implements CommandLineRunner { public static void main(String[] args) { SpringApplication.run(AlfrescoOutOfProcessRestapiApplication.class, args); } @Autowired NodesApi nodesApi; @Override public void run(String... args) throws Exception { // Some code here. } }
And here are the dependencies in my pom.xml file.
<properties> <java.version>17</java.version> <alfresco.api.version>5.2.2</alfresco.api.version> </properties> <repositories> <repository> <id>alfresco-public</id> <url>https://artifacts.alfresco.com/nexus/content/groups/public</url> </repository> </repositories> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <!-- https://mvnrepository.com/artifact/org.alfresco/alfresco-acs-java-rest-api-spring-boot-starter --> <dependency> <groupId>org.alfresco</groupId> <artifactId>alfresco-acs-java-rest-api-spring-boot-starter</artifactId> <version>${alfresco.api.version}</version> </dependency> <!-- https://mvnrepository.com/artifact/org.alfresco/alfresco-apa-java-rest-api-spring-boot-starter --> <dependency> <groupId>org.alfresco</groupId> <artifactId>alfresco-apa-java-rest-api-spring-boot-starter</artifactId> <version>${alfresco.api.version}</version> </dependency> <!-- https://mvnrepository.com/artifact/org.alfresco/alfresco-java-event-api-spring-boot-starter --> <dependency> <groupId>org.alfresco</groupId> <artifactId>alfresco-java-event-api-spring-boot-starter</artifactId> <version>${alfresco.api.version}</version> </dependency> </dependencies>
Best regards.
04-10-2023 12:16 AM
You may try adding configuration with @EnableAutoConfiguration, like in this sample:
07-19-2023 01:29 AM
Hi Angel,
@EnableAutoConfiguration is implicit in @SpringBootApplication annotation.
I have the same problem. Step to reproduce:
- start.spring.io with java 17 and spring boot 3.1.1 (last stable version of 3.1)
- add java sdk maven repo and dependency
org.alfresco:alfresco-acs-java-rest-api-spring-boot-starter:5.2.2
- create a Test Controller (empty if you want...) and add NodesApi with @Autowired annotation
With previous java sdk version it works.
07-19-2023 04:37 AM
After a deep investigation, I found that alfresco-java-sdk 5.2.2 (last stable release) doesn't work with spring boot 3.1.x
Compiling alfresco-java-sdk 6.0.0-SNAPSHOT from github (it's not uploaded on maven repo), works fine with spring boot 3.1.x
The README file should be updated in alfresco-java-sdk project. I think that a compatibility matrix could be improve understanding
Federico
Explore our Alfresco products with the links below. Use labels to filter content by product module.