2016-03-26 70 views
-1

我写了一个简单的spring启动多模块。一个父模块有两个子模块访问和Web模块。我把下面的所有模块配置。此示例项目正常工作时,它是一个模块,但是当我把它在多个模块抛出此异常春季启动maven多模块

更新:完整的堆栈跟踪

异常在线程“主” java.lang.IllegalArgumentException异常:无效的参数的语法: - = 在org.springframework.core.env.SimpleCommandLineArgsParser.parse(SimpleCommandLineArgsParser.java:75) 在org.springframework.core.env.SimpleCommandLinePropertySource(SimpleCommandLinePropertySource.java:87) 在有机.springframework.boot.SpringApplication.configurePropertySources(SpringApplication.java:44 3) at org.springframework.boot.SpringApplication.configureEnvironment(SpringApplication.java:414) at org.springframework.boot.SpringApplication.run(SpringApplication.java:284) at org.springframework.boot.SpringApplication.run( SpringApplication.java:961) 在org.springframework.boot.SpringApplication.run(SpringApplication.java:950) 在com.spring.controller.Application.main(Application.java:21)

我会如果需要,请提供更多关于样本的信息。

父模块:

<parent> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-parent</artifactId> 
    <version>1.2.7.RELEASE</version> 
</parent> 
<modelVersion>4.0.0</modelVersion> 
<name>parent</name> 
<groupId>com.spring</groupId> 
<artifactId>parent</artifactId> 
<version>0.0.1-SNAPSHOT</version> 
<packaging>pom</packaging> 
<properties> 
    <maven.compiler.source>1.8</maven.compiler.source> 
    <maven.compiler.target>1.8</maven.compiler.target> 
    <spring-boot.version>1.3.3.RELEASE</spring-boot.version> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> 
</properties> 

<modules> 
    <module>access</module> 
    <module>web</module> 
</modules> 

访问模块配置是这

<parent> 
    <artifactId>parent</artifactId> 
    <groupId>com.spring</groupId> 
    <version>0.0.1-SNAPSHOT</version> 
</parent> 
<modelVersion>4.0.0</modelVersion> 

<artifactId>access</artifactId> 
<dependencies> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-thymeleaf</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> 
    <dependency> 
     <groupId>org.springframework.data</groupId> 
     <artifactId>spring-data-rest-core</artifactId> 
     <version>2.2.1.RELEASE</version> 
    </dependency> 
</dependencies> 
<build> 
    <plugins> 
     <plugin> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-maven-plugin</artifactId> 
      <configuration> 
       <executable>true</executable> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <configuration> 
       <useSystemClassLoader>false</useSystemClassLoader> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 

和网络模块配置是这样的:

<parent> 
    <artifactId>parent</artifactId> 
    <groupId>com.spring</groupId> 
    <version>0.0.1-SNAPSHOT</version> 
</parent> 
<modelVersion>4.0.0</modelVersion> 

<artifactId>web</artifactId> 
<dependencies> 
    <dependency> 
     <groupId>com.spring</groupId> 
     <artifactId>access</artifactId> 
     <version>0.0.1-SNAPSHOT</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-thymeleaf</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-data-jpa</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-data-rest</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>mysql</groupId> 
     <artifactId>mysql-connector-java</artifactId> 
    </dependency> 
</dependencies> 

<properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    <start-class>com.spring.controller.Application</start-class> 
    <java.version>1.8</java.version> 
</properties> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.springframework.boot</groupId> 
      <artifactId>spring-boot-maven-plugin</artifactId> 
      <configuration> 
       <executable>true</executable> 
      </configuration> 
     </plugin> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <configuration> 
       <useSystemClassLoader>false</useSystemClassLoader> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 

和应用类代码为:

@Configuration 
@ComponentScan("com.spring.controller") 
@EnableJpaRepositories 
@Import(RepositoryRestMvcConfiguration.class) 
@EnableAutoConfiguration 
@PropertySource("application.properties") 
public class Application { 

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

什么是完整的堆栈跟踪? –

+0

@安迪威尔金森,我把堆满的痕迹。 – ali

回答

2

该例外状态表示您错过了使用SpringApplication.run(...)方法。它看起来像你传递 - =作为参数。

查看Spring Boot指南的使用或给我们您的代码片段。

https://spring.io/guides/gs/spring-boot/

编辑1:

的问题来自于你的运行配置的参数。

args中的参数不正确。 --=是不可接受的。

+0

感谢您的回答。请看看我更新的问题。我添加应用程序类。 – ali

+1

问题来自您的运行配置的参数。 参数中的参数不正确。 –