Crabime
Crabime

Reputation: 684

how to Integrate spring boot in project

Maybe my question is a little base, but i seldom use spring boot. Here i create a such project and have some questions below:

  1. why i need to use add spring-boot-starter-parent as parent? what's the usage of <relativepath /> usage in it?
  2. I have already add spring-boot-starter-web in pom.xml, everything is ok but my .java file appears FilterRegistrationBean not found, it's a compile error ! why? Here i can see such jar file dependencies in project structure(Here i'm using Idea 2016)

Here is my project pom.xml file snippet, Hope some one can give me a hand, thanks:

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

update:

after almost half an hour discovering, i found it's a Idea bug. maybe such class can not find under classpath before, but after changing the right version dependencies and re-organize import(just remove such error import and auto-import new one), then application can start normally. So strange ! maybe i should report to JetBrain. finally, no matter what, thanks every body ever give me hints, I will give upvote for you ~.~.

Here is my final pom.xml, if you want to check your dependencies which already download in Idea, you can see *.iml file(there are many type='library' entry):

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

Upvotes: 0

Views: 126

Answers (1)

mikeskaife
mikeskaife

Reputation: 24

May not fix the actual issue, but you don't need to include a version on all the starters in your pom.xml.

You've specified a version for spring-boot-starter-parent, so that will take care of using the correct version for all the other starters in your dependencies.

Upvotes: 1

Related Questions