Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我应该如何在spring boot中运行前端集成测试?_Spring_Maven_Spring Boot_Integration Testing_Spring Boot Maven Plugin - Fatal编程技术网

我应该如何在spring boot中运行前端集成测试?

我应该如何在spring boot中运行前端集成测试?,spring,maven,spring-boot,integration-testing,spring-boot-maven-plugin,Spring,Maven,Spring Boot,Integration Testing,Spring Boot Maven Plugin,我有一个简单的spring boot项目,它的maven结构如下: project - backend (spring boot) - frontend (angular) 我配置了项目,以便在maven的集成测试阶段运行*IT.java类,它们正在使用H2数据库成功地测试Spring Boot REST API 我正在尝试配置项目,以便在项目的集成测试阶段运行与浏览器交互的cucumber测试。cucumber测试启动正常,但失败,原因很简单,当spring启动应用程序启动时,ang

我有一个简单的spring boot项目,它的maven结构如下:

project
  - backend (spring boot)
  - frontend (angular)
我配置了项目,以便在maven的集成测试阶段运行*IT.java类,它们正在使用H2数据库成功地测试Spring Boot REST API

我正在尝试配置项目,以便在项目的集成测试阶段运行与浏览器交互的cucumber测试。cucumber测试启动正常,但失败,原因很简单,当spring启动应用程序启动时,angular文件没有得到服务

在backend/src/main/resources/static中,我有一个简单的index.html文件。当cucumber测试运行时,它们会打开一个浏览器,我可以看到该文件的内容

在后端模块(war)pom中,我从角度构建复制dist内容

    <build>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>${spring.boot.version}</version>
            <executions>
                <execution>
                    <goals>
                        <goal>build-info</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <mainClass>some.package.Boot</mainClass>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>${maven.war.plugin.version}</version>
            <configuration>
                <warName>${root.context}</warName>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
        <resources>
          <resource>
           <directory>../frontend/<appname>/dist/frontend</directory>
            <!--<targetPath>src/main/resources/static</targetPath>-->
            <targetPath>static</targetPath>
           </resource>
         </resources>
   </build>

org.springframework.boot
springbootmaven插件
${spring.boot.version}
构建信息
some.package.Boot
org.apache.maven.plugins
maven战争插件
${maven.war.plugin.version}
${root.context}
假的
../frontend//dist/frontend
静止的
在生成的war文件中,角度文件被打包成WEB-INF/classes/static/

您会注意到,从上面我还尝试将angular代码复制到resources/static中,但这会将文件放在target/classes/src/main/resources/static中,因此这不是正确的方法

但是cucumber测试在运行时仍然只能看到src/main/resources/static中index.html文件的内容

我们可能会将angular应用程序移动到与java/webapp代码相同的src树中,但这不是一个选项

我如何说服SpringBoot在目标中使用war,而不是它看起来在做什么,以及从源代码中服务内容

版本: 爪哇11

Maven war插件3.2.2

Springboot版本在父pom中定义为2.1.3.0版本

  • SpringBootStarterWeb
  • 弹簧启动启动器数据rest
  • spring引导启动器数据jpa
  • spring引导启动器数据jdbc
  • 弹簧靴启动器tomcat(不确定我是否需要这个)