这次更新,博客加入了搜索功能,使用的Lucene做的搜索,分词器采用的IKAnalyzer。因为IKAnalyzer没有在Maven的中央库中,所以我们得手动添加Jar包到我们的Maven项目中。
1、首先我在项目根目录中创建一个lib文件夹,将jar包拷贝到lib文件夹下
![](https://img-blog.csdn.net/20150202103530315?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvRWR3YXJkX3FpbmdfTGVl/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center)
2、然后我们在maven的pom.xml中配置
- <groupId>org.wltea.analyzer</groupId>
- <artifactId>IKAnalyzer</artifactId>
- <version>2012FF_u1</version>
- <scope>system</scope>
- <systemPath>${project.basedir}/lib/IKAnalyzer2012FF_u1.jar
- </systemPath>
3、这里的groupId和artifactId以及version都是可以随便填写的 ,scope必须填写为system,而systemPath我们现在我们jar包的地址就可以了
4、最后我们必须在maven打包的过程中加入我们这个jar包。因为项目运行的时候需要这个Jar,并且我们得拷贝在WEB-INF/lib目录下
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-war-plugin</artifactId>
- <configuration>
- <webResources>
- <resource>
- <directory>${project.basedir}/lib</directory>
- <targetPath>WEB-INF/lib</targetPath>
- <filtering>false</filtering>
- <includes>
- <include>**/*.jar</include>
- </includes>
- </resource>
- </webResources>
- </configuration>
- <version>2.1.1</version>