“brew 服务启动 tomcat”忽略 ~/.zshrc 环境变量
我正在安装 java8 和 tomcat9,如下所示:
brew install adoptopenjdk/openjdk/adoptopenjdk8 --cask
ln -s $(/usr/libexec/java_home -v 1.8) /opt/homebrew/opt/openjdk
echo 'export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)' >> ~/.zshrc
brew install tomcat@9 --ignore-dependencies
brew services start tomcat@9
我将 java 的位置导出到存储在我的用户 ~/.zshrc
文件中的名为 JAVA_HOME
的环境变量,因为 catalina.sh 需要环境变量JAVA_HOME
设置为工作。
如果我使用终端启动 catalina.sh ,效果很好,但是 brew services start tomcat@9
不起作用,因为 launchctl 服务忽略了存储在我的用户 ~/.zshrc
文件中的名为 JAVA_HOME
的环境变量。所以它忽略 ~/.zshrc
文件。
在 Mac OSX Catalina
中,这工作得很好,但在 Monterey
中却失败了
I'm installing java8 and tomcat9 like this:
brew install adoptopenjdk/openjdk/adoptopenjdk8 --cask
ln -s $(/usr/libexec/java_home -v 1.8) /opt/homebrew/opt/openjdk
echo 'export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)' >> ~/.zshrc
brew install tomcat@9 --ignore-dependencies
brew services start tomcat@9
I export the location of java to a environmentan variable called JAVA_HOME
stored in my user ~/.zshrc
file because catalina.sh needs the environmentan variable JAVA_HOME
setted to work.
If i start catalina.sh using terminal, works perfectly, butbrew services start tomcat@9
doesn't work because the launchctl service ignores the environmentan variable called JAVA_HOME
stored in my user ~/.zshrc
file. So it is ignoring the ~/.zshrc
file.
In Mac OSX Catalina
this worked perfectly, but it's failing in Monterey
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这对我在蒙特利有用:
如果您希望它在重新启动后持续存在,请参阅这个答案,这对我来说不是问题,因为我很少重新启动,更喜欢手动启动 Tomcat。
This worked for me on Monterey:
See this answer if you want it to persist across reboots, not an issue for me as I rarely reboot and prefer to start Tomcat manually.