问题描述:最近在学习JavaWeb需要要用到服务器,果断安装Tomcat,安装完成后发现在IntelliJ Idea中启动时老是会出现如下警告:The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path:...查阅和参考了一大坨资料后总结一下解决方法。
1. 下载并编译APR
在终端编译APR
cd /<your_apr_dir>/apr
CFLAGS='-arch x86_64' ./configure
make
make install
2. 下载并编译APR-util
在终端编译APR-util
cd /<your_apr-util_dir>/apr-util
CFLAGS='-arch x86_64' ./configure --with-apr=/usr/local/apr/bin/apr-1-config
make
make install
3. 安装OpenSSL
安装OpenSSL之前首先需要在Homebrew安装Homebrew.
安装完成后打开终端输入下面命令
brew install openssl
编译Tomcat native库
Tomcat native库已经提供在下载好的Tomcat中了. 我下载的Tomcat版本是apache-tomcat-8.5.4
cd /<your_tomcat_dir>/bin
gunzip tomcat-native.tar.gz
tar xf tomcat-native.tar
cd /<your_tomcat-native_dir>/native
CFLAGS='-arch x86_64' ./configure --with-apr=/usr/local/apr --with-ssl=/usr/local/opt/openssl --with-java-home=/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home
make
make install
配置Tomcat关联路径
sudo ln -s /usr/local/apr/lib/libtcnative-1.dylib /Library/Java/Extensions/
在IntelliJ idea中启动Tomcat,如果看到下面的提示则证明APR安装成功.
17-Jul-2016 09:43:24.134 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
17-Jul-2016 09:43:24.134 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]