2017-09-26 148 views
0

正如我通常做的(我做了很多次)我使用SpringInitializr生成SpringBoot項目並獲取項目的zip文件。然後我解壓縮文件並用IntelliJ IDEA Community Edition打開。 發生了一件非常奇怪的事情:它不會導入我的Project內的src文件夾,但只會創建一個.gitignore文件並導入除src文件夾之外的任何內容。 如果我嘗試使用Maven構建怪異項目,它將返回一個錯誤,指出我生成的POM不可解析。現在IntelliJ IDEA麻煩打開SpringBoot項目

,我必須說,POM是生成的一個,如此看來無錯誤:

<?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.pepe.pietro</groupId> 
<artifactId>PietroP</artifactId> 
<version>0.0.1-SNAPSHOT</version> 
<packaging>jar</packaging> 

<name>PietroP</name> 
<description>Demo project for Spring Boot</description> 

<parent> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-parent</artifactId> 
    <version>1.5.7.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-data-jpa</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-web</artifactId> 
    </dependency> 

    <dependency> 
     <groupId>com.h2database</groupId> 
     <artifactId>h2</artifactId> 
     <scope>runtime</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-test</artifactId> 
     <scope>test</scope> 
    </dependency> 
</dependencies> 

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

這是SpringInitializr下載的項目: enter image description here

而且這是圖片IntelliJ IDEA的屏幕試圖打開它之後。 enter image description here 我錯過了什麼?

回答

3

根據屏幕截圖中顯示的錯誤消息,它看起來像您本地Maven回購中的spring-boot-starter-parent-1.5.7.RELEASE.pom副本已損壞。

你可以刪除此文件...

/Users/allesandroargentieri/.m2/repository/org/springframework/boot/spring-boot-starter-parent/1.5.7.RELEASE/spring-boot-starter-parent-1.5.7.RELEASE.pom 

...然後重新導入到您的項目的IntelliJ,這將有強制刪除spring-boot-starter-parent-1.5.7.RELEASE.pom的副作用與非腐敗的副本希望更換。