Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to turn on apr function in spring boot

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

Spring boot how to turn on the apr function, for this question, this article introduces the corresponding analysis and answer in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.

Ubuntu

Sudo apt install libapr1 libapr1-dev libaprutil1 libtcnative-1

Add the parameter-Djava.library.path=/usr/lib/x86_64-linux-gnu when running jar, as follows:

Java-jar-Djava.library.path=/usr/lib/x86_64-linux-gnu.

Centos

There is no specific environment for testing, but the idea is the same: install apr and tomcat-native with yum, then run jar, and if you can't find it, add the-Djava.library.path parameter.

Alpine

Usually used in docker, the following code can be added to the Dockerfile file, and the runtime does not need to specify-Djava.library.path.

Apk add apr & apk add apr-util & & apk add apr-dev & & apk add tomcat-nativespring boot@Configurationpublic class APRConfig {@ Value ("${apr}") private boolean apr; @ Bean public TomcatServletWebServerFactory servletContainer () {TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory (); if (apr) {tomcat.setProtocol ("org.apache.coyote.http11.Http11AprProtocol"); tomcat.addContextLifecycleListeners (new AprLifecycleListener ()) } return tomcat;}} start

After starting successfully, you can see the [http-apr-8080] output

This is the answer to the question about how spring boot enables apr. I hope the above content can be of some help to you. If you still have a lot of doubts to solve, you can follow the industry information channel to learn more about it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report