【问题标题】:Issue in running springboot MVC project运行spring boot MVC项目的问题
【发布时间】:2018-02-14 19:01:25
【问题描述】:

当尝试使用 springBoot 和 Tomcat Embeded 运行我的第一个 HelloWorld 应用程序时,出现以下异常:

org.springframework.beans.factory.BeanDefinitionStoreException: 失败 读取候选组件类嵌套异常是 java.lang.IllegalStateException:无法评估 org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$EmbeddedDatabaseConfiguration 上的条件 由于未找到 org/springframework/dao/DataAccessException。制作 确保您自己的配置不依赖于该类。这也可以 如果您正在 @ComponentScanning 一个 springframework 包(例如
如果您错误地将@ComponentScan 放入默认包中)

这是我的入口点示例类配置:

@SpringBootApplication
public class Example extends SpringBootServletInitializer
{
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) 
    {
        return application.sources(Example.class);
    }

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

这是我的 WelcomeController 类:

package controler;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.Map;

@Controller
public class WelcomeController 
{
    // inject via application.properties
    @Value("${welcome.message:test}")
    private String message = "Hello World";

    @RequestMapping("/")
    public String welcome(Map<String, Object> model) 
    {
        model.put("message", this.message);
        return "welcome";
    }
}

这是我的 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>

<groupId>com.springBoot</groupId>
<artifactId>SpringbootHelloword</artifactId>
<version>1.0-SNAPSHOT</version>

 <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.9.RELEASE</version>
 </parent>

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

    <!-- Tomcat embedded container-->
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-tomcat</artifactId>
        <scope>provided</scope>
    </dependency>

    <!-- JSTL for JSP -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
    </dependency>

    <!-- Need this to compile JSP -->
    <dependency>
        <groupId>org.apache.tomcat.embed</groupId>
        <artifactId>tomcat-embed-jasper</artifactId>
        <scope>provided</scope>
    </dependency>

    <!-- Need this to compile JSP,
        tomcat-embed-jasper version is not working, no idea why -->
    <dependency>
        <groupId>org.eclipse.jdt.core.compiler</groupId>
        <artifactId>ecj</artifactId>
        <version>4.6.1</version>
        <scope>provided</scope>
    </dependency>

    <!-- Optional, test for static content, bootstrap CSS-->
    <dependency>
        <groupId>org.webjars</groupId>
        <artifactId>bootstrap</artifactId>
        <version>3.3.7</version>
    </dependency>

 </dependencies>


</project>

【问题讨论】:

标签: java spring-mvc spring-boot


【解决方案1】:

我更改了服务器端口,因为它被另一个应用程序使用并且它可以正常工作。

【讨论】:

    猜你喜欢
    • 2020-07-21
    • 2020-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-03
    • 2020-01-14
    • 2016-08-13
    • 2018-08-11
    相关资源
    最近更新 更多