Skip to main content
Bumped by Community user
adicionou 185 caracteres ao conteúdo
Fonte Link
package mz.com.centropontoencontro;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class CentroPontoEncontroApplication {

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

}
@SpringBootApplication
public class CentroPontoEncontroApplication {

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

}
package mz.com.centropontoencontro;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class CentroPontoEncontroApplication {

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

}
adicionou 3874 caracteres ao conteúdo
Fonte Link

Classe de execução da aplicação

@SpringBootApplication
public class CentroPontoEncontroApplication {

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

}

arquivo 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 https://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.9.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>mz.com.centropontoencontro</groupId>
    <artifactId>centro-ponto-encontro</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>centro-ponto-encontro</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <!-- <dependency> -->
        <!-- <groupId>org.springframework.boot</groupId> -->
        <!-- <artifactId>spring-boot-starter-security</artifactId> -->
        <!-- </dependency> -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- <dependency> -->
        <!-- <groupId>org.springframework.security</groupId> -->
        <!-- <artifactId>spring-security-test</artifactId> -->
        <!-- <scope>test</scope> -->
        <!-- </dependency> -->

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>webjars-locator</artifactId>
            <version>0.37</version>
        </dependency>

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>bootstrap</artifactId>
            <version>4.3.1</version>
        </dependency>

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>popper.js</artifactId>
            <version>1.15.0</version>
        </dependency>

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>jquery</artifactId>
            <version>3.4.1</version>
        </dependency>

        <dependency>
            <groupId>nz.net.ultraq.thymeleaf</groupId>
            <artifactId>thymeleaf-layout-dialect</artifactId>
        </dependency>

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>font-awesome</artifactId>
            <version>5.11.2</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

O que devo fazer? Obrigado

O que devo fazer? Obrigado

Classe de execução da aplicação

@SpringBootApplication
public class CentroPontoEncontroApplication {

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

}

arquivo 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 https://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.9.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
    <groupId>mz.com.centropontoencontro</groupId>
    <artifactId>centro-ponto-encontro</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>centro-ponto-encontro</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <!-- <dependency> -->
        <!-- <groupId>org.springframework.boot</groupId> -->
        <!-- <artifactId>spring-boot-starter-security</artifactId> -->
        <!-- </dependency> -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- <dependency> -->
        <!-- <groupId>org.springframework.security</groupId> -->
        <!-- <artifactId>spring-security-test</artifactId> -->
        <!-- <scope>test</scope> -->
        <!-- </dependency> -->

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>webjars-locator</artifactId>
            <version>0.37</version>
        </dependency>

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>bootstrap</artifactId>
            <version>4.3.1</version>
        </dependency>

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>popper.js</artifactId>
            <version>1.15.0</version>
        </dependency>

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>jquery</artifactId>
            <version>3.4.1</version>
        </dependency>

        <dependency>
            <groupId>nz.net.ultraq.thymeleaf</groupId>
            <artifactId>thymeleaf-layout-dialect</artifactId>
        </dependency>

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>font-awesome</artifactId>
            <version>5.11.2</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

O que devo fazer? Obrigado

Fonte Link

Erro ao iniciar ApplicationContext através de uma aplicação Spring

Boas colegas. Estou a começar a desenvolver com o spring, porem estou com um problema não estou a conseguir executar a minha aplicação web, sempre que executo lança a seguinte mensagem de erro no spring:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-10-12 11:00:08.063 ERROR 13660 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

Field catDAO in mz.com.centropontoencontro.service.CategoriaLivroServiceImpl required a bean of type 'mz.com.centropontoencontro.dao.CategoriaLivroDAO' 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 'mz.com.centropontoencontro.dao.CategoriaLivroDAO' in your configuration.

Abaixo deixo as classes e interfaces.

classe CategoriaLivroDAOImpl

@Repository
public abstract class CategoriaLivroDAOImpl extends AbstractDAO<CategoriaLivro> implements CategoriaLivroDAO {
}

interface CategoriaLivroDAO

public interface CategoriaLivroDAO {

            void save(CategoriaLivro catLivro);
            
            void update(CategoriaLivro catLivro);
            
            void delete(Long id);
            
            CategoriaLivro findById(Long id);
            
            List<CategoriaLivro> findAll();
        }

Interface CategoriaLivroService

public interface CategoriaLivroService {

        void salvar(CategoriaLivro categoriaLivro);

        void editar(CategoriaLivro categoriaLivro);

        void excluir(Long id);

        CategoriaLivro procurarPorId(Long id);

        List<CategoriaLivro> pesquisarTodos();

    }

Classe CategoriaLivroServiceImpl

@Transactional(readOnly = false) @Service public class CategoriaLivroServiceImpl implements CategoriaLivroService {

        @Autowired
        private CategoriaLivroDAO catDAO;
        
        @Override
        public void salvar(CategoriaLivro categoriaLivro) {
            catDAO.save(categoriaLivro);
        }

        @Override
        public void editar(CategoriaLivro categoriaLivro) {
            catDAO.update(categoriaLivro);
        }

        @Override
        public void excluir(Long id) {
            catDAO.delete(id);
        }

        @Transactional(readOnly = true)
        @Override
        public CategoriaLivro procurarPorId(Long id) {
            
            return catDAO.findById(id);
        }

        @Transactional(readOnly = true)
        @Override
        public List<CategoriaLivro> pesquisarTodos() {
            return catDAO.findAll();
        }

    }

O que devo fazer? Obrigado