简体   繁体   中英

Spring Boot maven project from Eclipse doesn't work in Intellij

I have working spring boot maven project created in eclipse. Then i import its to Intellij Ultimate, everything goes fine, click run and:

and after this i have errors:

2017-02-15 12:46:58.459 ERROR 6020 --- [  restartedMain] o.s.boot.SpringApplication               : Application startup failed

java.lang.IllegalStateException: Could not evaluate condition on org.springframework.boot.devtools.autoconfigure.DevToolsDataSourceAutoConfiguration due to javax/servlet/Filter not found. Make sure your own configuration does not rely on that class. This can also happen if you are @ComponentScanning a springframework package (e.g. if you put a @ComponentScan in the default package by mistake)

....

2017-02-15 12:46:58.478 ERROR 6020 --- [  restartedMain] o.s.b.f.s.DefaultListableBeanFactory     : Destroy method on bean with name 'org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory' threw an exception

java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.context.annotation.AnnotationConfigApplicationContext@2f6c79e1: startup date [Wed Feb 15 12:46:56 CET 2017]; root of context hierarchy

Where is the problem ?

My 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.twistezo</groupId>
<artifactId>StickyNotes</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>

<name>StickyNotes</name>
<description>StickyNotes SpringBoot app</description>

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.4.4.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <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>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
    <dependency>
    <groupId>org.thymeleaf.extras</groupId>
        <artifactId>thymeleaf-extras-springsecurity4</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
    </dependency>
     <dependency>
       <groupId>net.sourceforge.nekohtml</groupId>
        <artifactId>nekohtml</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-data-jpa</artifactId>
    </dependency>
    <dependency>
         <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
    </dependency>
</dependencies>

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

Starter class

@SpringBootApplication
public class StickyNotesApplication {

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

There is a known issue with IntelliJ IDEA Maven support and provided dependencies.

A workaround for your problem would be to change spring-boot-starter-tomcat dependency scope from provided to compile .

See also a related discussion for a similar case, but with a different dependency.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM