如何向shell脚本添加java库引用
我在springClasspath文件中有以下spring引用JAR如何向shell脚本添加java库引用,java,bash,shell,unix,Java,Bash,Shell,Unix,我在springClasspath文件中有以下spring引用JAR CLASSPATH=/apps/cab/spring/spring-core-3.1.1.RELEASE.jar:/apps/cab/spring/commons-logging-1.2.jar:/apps/cab/spring/spring-aop-4.2.2.RELEASE.jar:/apps/cab/spring/spring-beans-4.2.2.RELEASE.jar export CLASSPATH
CLASSPATH=/apps/cab/spring/spring-core-3.1.1.RELEASE.jar:/apps/cab/spring/commons-logging-1.2.jar:/apps/cab/spring/spring-aop-4.2.2.RELEASE.jar:/apps/cab/spring/spring-beans-4.2.2.RELEASE.jar
export CLASSPATH
我想将springClasspath文件引用到我的shell脚本文件start\u order.sh,以便我的java程序引用所需的spring依赖项。我怎么做?因为您计划在shell脚本中使用的
springClasspath
文件中有多个声明。您需要它来source
脚本中的文件,以便进一步使用变量
通过在脚本中寻源文件,可以使其中定义的变量在运行脚本的子shell中可用。例如,在将解释器设置为bash
后的start\u order.sh
行中,按如下所示源代码脚本
#!/usr/bin/env bash
# Give the full path to the file if it is present in another location
. ./springClasspath
# with the above source done, the variables can be used as below in your
# script
echo "$CLASSPATH"
请记住,
export
-在这种情况下,除非您将文件和脚本的源代码设置为与变量集在同一父shell中运行,否则将文件导出将不起作用。springClasspath
是一个单独的文件吗?您想在其他脚本中使用其中定义的变量CLASSPATH
?什么类型的文件是CLASSPATH
除了变量初始化之外还有其他行吗?springClasspath是一个单独的文件。是的,我想在其他脚本中也使用CLASSPATH变量。springClasspath文件只包含库依赖项