2016-02-06 169 views
0

我是新的春季啓動,並試圖在春季啓動創建一個非常基本的應用程序。但是,在創建我的應用程序時出現此錯誤。無法找到或加載主類BasicApp.Application

無法找到或加載

我的應用程序有兩個班一個Controller類和一個Main類主類BasicApp.Application。這裏是我的代碼:

Application.java

package BasicApp; 

import org.springframework.boot.SpringApplication; 

public class Application 
{ 
    public static void main(String[] args) { 

     SpringApplication.run(Application.class, args); 
    } 
} 

MainController.java

package BasicApp; 

import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 
import org.springframework.stereotype.Controller; 
import org.springframework.web.bind.annotation.RequestMapping; 
import org.springframework.web.bind.annotation.ResponseBody; 

@Controller 
@EnableAutoConfiguration 
public class MainController 
{ 
    @RequestMapping("/send") 
    @ResponseBody 
    public String sendMessage() 
    { 
     return("M sending message"); 
    } 
} 

的pom.xml

<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>SpringBootSecond</groupId> 
<artifactId>SpringBootSecond</artifactId> 
<version>0.0.1-SNAPSHOT</version> 
<properties>  
    <!-- Spring version --> 
    <spring-framework.version>4.1.0.RELEASE</spring-framework.version>  
    <!-- ActiveMQ version --> 
    <activemq.version>5.10.0</activemq.version> 
</properties> 

<parent> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-parent</artifactId> 
    <version>1.3.2.RELEASE</version> 
</parent> 

<dependencies> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-web</artifactId> 
     <version>1.3.2.RELEASE</version> 
    </dependency> 

    <!-- Spring aritifacts --> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-context</artifactId> 
     <version>4.2.0.RELEASE</version> 
    </dependency> 

    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-jms</artifactId> 
     <version>4.2.4.RELEASE</version> 
    </dependency> 

    <!-- ActiveMQ Artifacts --> 
    <dependency> 
     <groupId>org.apache.activemq</groupId> 
     <artifactId>activemq-spring</artifactId> 
     <version>${activemq.version}</version> 
    </dependency> 
</dependencies> 

<!-- Using JDK 1.7 for compiling --> 
<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>2.5.1</version> 
      <configuration> 
       <source>1.7</source> 
       <target>1.7</target> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 

<!-- <parent> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-starter-parent</artifactId> 
      <version>1.3.2.RELEASE</version> 
     </parent> 

     <dependencies> 
      <dependency> 
       <groupId>org.springframework.boot</groupId> 
       <artifactId>spring-boot-starter-web</artifactId> 
      </dependency> 
     </dependencies> 

     <properties> 
      <java.version>1.8</java.version> 
     </properties> 

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

     <repositories> 
      <repository> 
       <id>spring-releases</id> 
       <url>https://repo.spring.io/libs-release</url> 
      </repository> 
     </repositories> 
     <pluginRepositories> 
      <pluginRepository> 
       <id>spring-releases</id> 
       <url>https://repo.spring.io/libs-release</url> 
      </pluginRepository> 
     </pluginRepositories> --> 
</project> 

有人可以幫我解決這個錯誤嗎?

回答

1

將@SpringBootApplication註釋添加到您的應用程序類中,它將爲您執行所有配置。

0

查看構建錯誤,通常文件大小爲零,刪除maven文件夾中的錯誤文件

相關問題