我有一个Java应用程序,该应用程序在Localhost:9080和另一个Angular5 Project(AngularWeb(上运行,而在同一项目的WebContent文件夹中运行,该文件夹在其他端口Local -Host上运行:4200
根据要求,我需要集成两个项目以在Localhost上的同一服务服务器上运行:9080和(Java和Angular Projects(都需要位于同一位置,这就是为什么我在Web内容文件夹中拥有Angular Project的原因。
请帮助我了解缺少的东西。
首先:我在Angular项目中创建了一个proxy.conf.json文件,以定位Localhost:9080。
第二:我已经更改了包装。" start":" ng serve -proxy-conf proxy.conf.json",
第三:我在build.xml文件中添加了一些目标
...
...
<property name="project.angularWebPath" location="${project.webContentPathh}/angularweb" />
<target name="mkfolders">
<mkdir dir="${project.webContentPath}/js" />
<mkdir dir="${project.webContentPath}/css" />
<mkdir dir="${project.webContentPath}/img" />
<mkdir dir="${project.webContentPath}/lib" />
<mkdir dir="${project.webContentPath}/partials" />
</target>
<target name="mkfiles">
<touch file="${project.webContentPath}/js/app.js" />
<touch file="${project.webContentPath}/js/controller.js" />
<touch file="${project.webContentPath}/js/directives.js" />
<touch file="${project.webContentPath}/js/filters.js" />
<touch file="${project.webContentPath}/js/services.js" />
<touch file="${project.webContentPath}/index.html" />
</target>
<target name="ngBuild">
<echo>Building Angular Project</echo>
<exec executable="${project.angularWebPath}/node_modules/@angular/cli/bin/ng.cmd" failonerror="true">
<arg value="build" />
<arg value="--prod" />
<arg value="--bh" />
</exec>
<echo>Built Angular Project</echo>
</target>
<target name="angularBuild">
<antcall target="mkfolders" />
<antcall target="mkfiles" />
<!--<antcall target="npmInstall" />-->
<antcall target="ngBuild" />
</target>
...
...
现在,当我在ANT中运行AngularBuild时,它会产生以下错误
Buildfile: D:devopsrepositorykomponente_serverRechercheEARbuild.xml
[clover-env] Loading clover.xml: jar:file:/D:/devops/repository/komponente_server/Shared/testlib/clover.jar!/clover.xml
angularBuild:
[clover-env] Loading clover.xml: jar:file:/D:/devops/repository/komponente_server/Shared/testlib/clover.jar!/clover.xml
mkfolders:
[clover-env] Loading clover.xml: jar:file:/D:/devops/repository/komponente_server/Shared/testlib/clover.jar!/clover.xml
mkfiles:
[clover-env] Loading clover.xml: jar:file:/D:/devops/repository/komponente_server/Shared/testlib/clover.jar!/clover.xml
ngBuild:
[echo] Building Angular Project
BUILD FAILED
D:devopsrepositorykomponente_serverRechercheEARbuild.xml:71: The following error occurred while executing this line:
D:devopsrepositorykomponente_serverRechercheEARbuild.xml:60: Execute failed: java.io.IOException: Cannot run program "D:devopsrepositorykomponente_serverRechercheWebContentangularwebnode_modules@angularclibinng.cmd" (in directory "D:devopsrepositorykomponente_server"): CreateProcess error=2, The system cannot find the file specified
Total time: 6 seconds
ant的exec
任务直接在Windows中启动文件。尝试将executable
属性设置为仅cmd
本身,然后将文件作为参数传递。官方文档页面更详细地介绍了为什么是这样的:https://ant.apache.org/manual/tasks/exec.html
另外,通常是通过目标依赖性构建构建而不是使用antcall
任务的顺序列表。
<property name="project.angularWebPath" location="${project.webContentPathh}/angularweb" />
<target name="mkfolders">
<mkdir dir="${project.webContentPath}/js" />
<mkdir dir="${project.webContentPath}/css" />
<mkdir dir="${project.webContentPath}/img" />
<mkdir dir="${project.webContentPath}/lib" />
<mkdir dir="${project.webContentPath}/partials" />
</target>
<target name="mkfiles" depends="mkfolders">
<touch file="${project.webContentPath}/js/app.js" />
<touch file="${project.webContentPath}/js/controller.js" />
<touch file="${project.webContentPath}/js/directives.js" />
<touch file="${project.webContentPath}/js/filters.js" />
<touch file="${project.webContentPath}/js/services.js" />
<touch file="${project.webContentPath}/index.html" />
</target>
<target name="ngBuild" depends="mkfiles,mkfolders">
<echo message="Building Angular Project" />
<exec executable="cmd" failonerror="true">
<arg value="/C" />
<arg value="${project.angularWebPath}/node_modules/@angular/cli/bin/ng.cmd" />
<arg value="build" />
<arg value="--prod" />
<arg value="--bh" />
</exec>
<echo message="Built Angular Project" />
</target>
<target name="angularBuild" depends="mkfiles,mkfolders,ngBuild" />