Compass is a Java project encapsulated by Lucene, which makes full-text retrieval very easy in spring and hibernate environments and greatly improves the efficiency. Therefore, in myblog, I also used compass as the full-text index. You can find the compass configuration from the petclinic in the samples of compass. Classpath: ORG/Compass/sample/petclinic. cmd. xml Classpath: petclinic. CPM. xml File: // $ {user. Home}/Compass/petclinic Org. Compass. Spring. transaction. springsynctransactionfactory The index location configured here is the absolute path of the system. Most people may want the index to be placed in a sub-directory of the project, that is, the relative path. However File: // $ {user. Home}/Compass/petclinic Is /Compass/petclinic This is not acceptable. At the beginning, I modified it like this. In fact, let's take a look at the source code of localcompassbean to know how to do it. If (this. compasssettings! = NULL) {config. getsettings (). addsettings (this. compasssettings );}...... if (config. getsettings (). getsetting (compassenvironment. connection) = NULL & connection! = NULL) {config. getsettings (). setsetting (compassenvironment. connection, connection. getFile (). getabsolutepath ();} You can see that if compass is configured when you configure compasssettings. engine. in connection, compass will use the value you configured, that is, the absolute path. If you do not configure it, the connection value will be read, and the connection type is Org. springframework. core. io. resource, which is a spring-encapsulated Resource class. There are many access methods for file classpath, so you can use the relative path here. Remove the compass. Engine. Connection configuration in compasssettings, and add the connection configuration to implement the relative path. For example, the configuration in myblog Classpath: COM/jdkcn/compass /Lucene/Indexes Org. Compass. Spring. transaction. springsynctransactionfactory After the webapp is started, compass will create an index under the/Lucene/indexes directory of your app.