我正在尝试让 51Degrees.mobi 与我的 Maven、JSF 和 Java 项目一起工作,但是到目前为止我还没有运气。我已经从http://51degrees.mobi/Support/Documentation/Java.aspx下载了 2 个 jars并按照说明进行操作。我现在有一个看起来像这样的过滤器
import fiftyone.mobile.detection.BaseDeviceInfo;
import fiftyone.mobile.detection.Provider;
import fiftyone.mobile.detection.binary.BinaryException;
import fiftyone.mobile.detection.binary.Reader;
public void doFilter(ServletRequest request, ServletResponse response,FilterChain chain) throws IOException, ServletException {
HttpServletRequest httpRequest = (HttpServletRequest) request;
String s = httpRequest.getHeader("user-agent");
//Create a Provider object
Provider p;
try {
p = Reader.create();
} catch (BinaryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//Provider p = Reader.create(PATH_TO_PREMIUM_DATA);
//Read in a HttpServletRequest or User Agent String
BaseDeviceInfo b = p.getDeviceInfo(s);
//Get the value of a property
String result = b.getFirstPropertyValue("IsMobile");
//Check the property value
if(result.equals("True")){
System.out.println("This is mobile");
}
if(result.equals("False")){
System.out.println("This is not mobile");
}
//Before exiting your application, ensure you dispose of the Provide to
//release it's resources such as it's thread pool
p.destroy();
}
那不会引发任何错误。从网上看,我发现了我必须添加到 pom 文件中的依赖关系,我拥有它
<dependency><!-- Start 51Degrees.mobi dependencies -->
<groupId>mobi.51degrees</groupId>
<artifactId>detection</artifactId>
<version>2.1.15.1</version>
</dependency><!-- End 51Degrees.mobi dependencies -->
文件本身再次没有引发错误,但是当我在目录中使用 mvn clean install 时,出现以下错误
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[18,32] error: package fiftyone.mobile.detection does not exist
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[19,32] error: package fiftyone.mobile.detection does not exist
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[20,39] error: package fiftyone.mobile.detection.binary does not exist
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[21,39] error: package fiftyone.mobile.detection.binary does not exist
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[45,4] error: cannot find symbol
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[47,7] error: cannot find symbol
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[50,11] error: cannot find symbol
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[60,4] error: cannot find symbol
[INFO] 8 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.730s
[INFO] Finished at: Wed Nov 14 12:45:35 GMT 2012
[INFO] Final Memory: 16M/39M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.1:compile (default- compile) on project redirectionportal: Compilation failure: Compilation failure:
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[18,32] error: package fiftyone.mobile.detection does not exist
[ERROR]
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[19,32] error: package fiftyone.mobile.detection does not exist
[ERROR]
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[20,39] error: package fiftyone.mobile.detection.binary does not exist
[ERROR]
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[21,39] error: package fiftyone.mobile.detection.binary does not exist
[ERROR]
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[45,4] error: cannot find symbol
[ERROR]
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[47,7] error: cannot find symbol
[ERROR]
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[50,11] error: cannot find symbol
[ERROR]
[ERROR] \ea\portals\redirectionportal\src\main\java\com\filters\MyFilter.java:[60,4] error: cannot find symbol
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
有人有想法么?