依赖性问题“SpringBootServletInitializer无法解析为类型”。 [英] Dependencies issue "SpringBootServletInitializer cannot be resolved to a type"

查看:349
本文介绍了依赖性问题“SpringBootServletInitializer无法解析为类型”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到根据我的理解,SpringBootServletInitializer无法解析为类型
。这是一个依赖性问题。

I'm getting SpringBootServletInitializer cannot be resolved to a type as far as I understand this is a dependencies issue.

虽然我觉得编写Java代码很舒服,但这是我的第一个应用程序,使用 maven spring-boot 自然我很无能为力。

While I feel comfortable writing Java code, this is my firs Application using maven and spring-boot naturally I'm clueless.

pom.xml:

<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>

    <artifactId>univers-web</artifactId>
    <packaging>war</packaging>

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

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

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
        </dependency>
        <dependency>
            <groupId>com.vaadin</groupId>
            <artifactId>vaadin-spring-boot-starter</artifactId>
            <version>2.0.1</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <executable>true</executable>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

SpringBootApplication.java:

package com.thebyteguru.launcher;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;

public class SpringBootApplication extends SpringBootServletInitializer {

    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(SpringBootApplication.class);
    }

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

}

我可以看到相关的 jar 文件存在于 Maven Dependencies 文件夹中,而 import '所需的'es我注意到'es,但它们是空的(意思是intellisense找到包但不包含其中的类。)

I can see that the relevant jar files are present in the Maven Dependencies folder, and while import'ing the needed class'es I noticed that the package'es are there but they are "empty"(meaning intellisense finds the packages but not the classes inside them).

我缺少什么?

推荐答案

不要做任何新事只需按 Ctrl + Shift + o 你的eclipse会为你的项目添加正确的导入

Don't do anything new just press Ctrl+Shift+o in your eclipse it will add correct import to your project

这篇关于依赖性问题“SpringBootServletInitializer无法解析为类型”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆