![](/img/trans.png)
[英]How can I define specific jar in pom.xml to be deployed to TOMCAT/lib folder?
[英]How can I add jar file to project instead of adding to Tomcat lib folder?
通過這個github項目,我將Tomcat會話存儲在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相關類嗎? PS有一些示例,但我聽不懂: 在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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.