1
resposta

Erro ao executar projeto no SpringBoot

Field context in br.com.caelum.camel.Boot required a bean of type 'org.apache.camel.CamelContext' that could not be found.

The injection point has the following annotations:
    - @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'org.apache.camel.CamelContext' in your configuration.

Boot.java

@SpringBootApplication
public class Boot {

    @Autowired
    private CamelContext context;

    @PostConstruct
    public void init() throws Exception {
        context.addComponent("activemq", ActiveMQComponent.activeMQComponent("tcp://localhost:61616"));
    }

    public static void main(String[] args) {
        SpringApplication.run(Boot.class, args);
    }
}

ProdutoService.java

@Service
public class ProdutoService extends RouteBuilder {

    @Override
    public void configure() throws Exception {

        from("file:pedidos").
        to("activemq:queue:pedidos");

    }

}
1 resposta

Oi Allan,

Veja se o seu pom.xml está conforma abaixo:

<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/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <groupId>br.com.caelum</groupId>
    <artifactId>camel-alura</artifactId>
    <version>1.0-SNAPSHOT</version>
    <name>projeto-camel-alura</name>
    <url>http://maven.apache.org</url>

    <properties>
        <camel-version>2.16.1</camel-version>
   </properties>

  <dependencies>

    <dependency>
       <groupId>org.apache.camel</groupId>
       <artifactId>camel-core</artifactId>
       <version>${camel-version}</version>
    </dependency>

    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-xmljson</artifactId>
      <version>${camel-version}</version>
    </dependency>

    <dependency>
        <groupId>xom</groupId>
        <artifactId>xom</artifactId>
        <version>1.2.5</version>
    </dependency>

    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-http4</artifactId>
        <version>${camel-version}</version>
    </dependency>    

        <dependency>
        <groupId>org.apache.activemq</groupId>
        <artifactId>activemq-camel</artifactId>
        <version>5.6.0</version>
    </dependency>    

    <dependency>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-jms</artifactId>
        <version>${camel-version}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>2.4</version>
      </dependency>
      <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.4</version>
      </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.12</version>
    </dependency>

    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-slf4j-impl</artifactId>
        <version>2.4</version>
    </dependency>  

<!--     <dependency> -->
<!--         <groupId>org.apache.camel</groupId> -->
<!--         <artifactId>camel-sql</artifactId> -->
<!--         <version>${camel-version}</version> -->
<!--     </dependency> -->


<!--     <dependency> -->
<!--         <groupId>mysql</groupId> -->
<!--         <artifactId>mysql-connector-java</artifactId> -->
<!--         <version>5.1.36</version> -->
<!--     </dependency> -->

  </dependencies>



  <build>
    <finalName>projeto-camel-alura</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
  </build>
</project>

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software