2017-02-15 132 views
1

我有在eclipse中创建的spring boot maven项目。于是我进口其终极的IntelliJ,一切顺利,单击运行和:来自Eclipse的Spring Boot maven项目在Intellij中不起作用

并在此之后,我有错误:

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.spring[email protected]2f6c79e1: startup date [Wed Feb 15 12:46:56 CET 2017]; root of context hierarchy 

问题出在哪里?

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

入门级

@SpringBootApplication 
public class StickyNotesApplication { 

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

您是否在IDEA中使用Spring Boot运行/调试配置?将'spring-boot-starter-tomcat'范围更改为'compile'有帮助吗?请[见相关讨论](https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000088004)。 – CrazyCoder

+0

将'spring-boot-starter-tomcat'范围更改为'compile'有帮助。谢谢@ CrazyCoder – twistezo

回答

2

a known issue与IntelliJ IDEA的Maven支持和provided依赖。

解决您的问题的方法是将spring-boot-starter-tomcat依赖范围从provided更改为compile

另请参见a related discussion对于类似的情况,但具有不同的依赖性。

相关问题