如何在项目

时间:2018-02-28 11:52:19

标签: java maven spring-boot intellij-idea

也许我的问题有点基础,但我很少使用弹簧靴。在这里,我创建了一个这样的项目,并在下面提出一些问题:

  1. 为什么我需要使用add spring-boot-starter-parent作为父级?它中<relativepath />用法的用法是什么?
  2. 我已经在pom.xml中添加了spring-boot-starter-web,一切正常,但我的 .java文件显示FilterRegistrationBean未找到,这是编译错误!为什么?在这里,我可以在project structure(这里我使用的是Idea 2016)
  3. 中看到这样的jar文件依赖项

    这是我的项目pom.xml文件片段,希望有人可以帮我一臂之力,谢谢:

    <groupId>org.demo</groupId>
    <artifactId>spring-security-oauth2</artifactId>
    <version>1.0-SNAPSHOT</version>
    
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.5.RELEASE</version>
        <relativePath />
    </parent>
    
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>1.5.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
            <version>1.5.6.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.security.oauth</groupId>
            <artifactId>spring-security-oauth2</artifactId>
            <version>2.0.14.RELEASE</version>
            <exclusions>
                <exclusion>
                    <artifactId>jackson-mapper-asl</artifactId>
                    <groupId>org.codehaus.jackson</groupId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>
    

    更新

    经过近半个小时的发现,我发现这是一个想法错误。也许这样的类在classpath之前找不到,但是在更改正确的版本依赖关系并重新组织导入(只是删除这样的错误导入并自动导入新的)之后,应用程序可以正常启动。这么奇怪 !也许我应该向JetBrain报到。 最后,无论如何,感谢每一个身体都给我提示,我会放弃为你投票〜.~。

    这是我的最终pom.xml,如果您想检查已经在Idea中下载的依赖项,您可以看到*.iml文件(有很多type ='library'条目):

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.5.RELEASE</version>
        <relativePath />
    </parent>
    
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.security.oauth</groupId>
            <artifactId>spring-security-oauth2</artifactId>
            <version>2.0.14.RELEASE</version>
            <exclusions>
                <exclusion>
                    <artifactId>jackson-mapper-asl</artifactId>
                    <groupId>org.codehaus.jackson</groupId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>
    

1 个答案:

答案 0 :(得分:1)

可能无法修复实际问题,但您无需在pom.xml中的所有启动器中包含版本。

您已为spring-boot-starter-parent指定了一个版本,因此需要为依赖项中的所有其他启动器使用正确的版本。

相关问题