gpt4 book ai didi

java - 如何将 jar 文件添加到项目而不是添加到 Tomcat lib 文件夹?

转载 作者:行者123 更新时间:2023-11-28 22:16:00 25 4
gpt4 key购买 nike

通过这个 github 项目,我将 Tomcat session 存储在 Redis 中: https://github.com/chexagon/redis-session-manager

并且在 src/webapp/META-INF/context.xml 文件中我添加了新命令:

<Manager className="com.crimsonhexagon.rsm.redisson.SingleServerSessionManager"
endpoint="redis://localhost:6379"
sessionKeyPrefix="_ib_"
saveOnChange="false"
forceSaveAfterRequest="false"
dirtyOnMutation="false"
ignorePattern=".*\\.(ico|png|gif|jpg|jpeg|swf|css|js)$"
maxSessionAttributeSize="-1"
maxSessionSize="-1"
allowOversizedSessions="false"
connectionPoolSize="100"
database="0"
timeout="60000"
pingTimeout="1000"
retryAttempts="20"
retryInterval="1000"
/>

如果 jar 文件在 Tomcat 的 lib 文件夹中,那么一切都很好。但在生产中,如果我将 jar 添加到 lib 文件夹,则会导致错误。还有其他方法可以解决这个问题吗?我可以更改 context.xml 以便在我部署项目时,管理器 className 能够找到相关的类吗?附言有一些例子,但我不明白: Adding external resources to class-path in Tomcat 8

如有大神赐教,不胜感激。提前致谢

最佳答案

我可以找到解决方法。 maven 中有一个用于部署 war 文件的插件。使用此插件可以将文件添加到 war 文件。例如,我创建了名为 redis 的文件夹并将 jar 文件添加到其中。然后我添加了插件:

            <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>redis</directory>
<targetPath>WEB-INF/lib</targetPath>
</resource>
</webResources>
</configuration>
</plugin>

关于java - 如何将 jar 文件添加到项目而不是添加到 Tomcat lib 文件夹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52722558/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com