连接到tfs时出现以下错误。
线程中的异常" main" java.lang.UnsatisfiedLinkError:com.microsoft.tfs.jni.internal.platformmisc.NativePlatformMisc.nativeGetEnvironmentVariable
代码: 公共类ConnectionToVisualStudio {
public static TFSTeamProjectCollection connectToTFS()
{
System.setProperty("com.microsoft.tfs.jni.native.base-directory", "C:\\Users\\userName\\native");
TFSTeamProjectCollection tpc = null;
Credentials credentials;
credentials = new UsernamePasswordCredentials("username","password");
tpc = new TFSTeamProjectCollection(URIUtils.newURI("https://xyz.visualstudio.com/MyFirstProject"), credentials);
return tpc;
}
public static void main(final String[] args)
{
TFSTeamProjectCollection tpc;
tpc = ConnectionToVisualStudio.connectToTFS();
Project project = tpc.getWorkItemClient().getProjects().get("MyFirstProject");
// Find the work item type matching the specified name.
WorkItemType bugWorkItemType = project.getWorkItemTypes().get("Bug");
// Create a new work item of the specified type.
WorkItem newWorkItem = project.getWorkItemClient().newWorkItem(bugWorkItemType);
// Set the title on the work item.
newWorkItem.setTitle("Example Work Item");
// Add a comment as part of the change
newWorkItem.getFields().getField(CoreFieldReferenceNames.HISTORY).setValue(
"<p>Created automatically by a sample</p>");
// Save the new work item to the server.
newWorkItem.save();
System.out.println("Work item " + newWorkItem.getID() + " successfully created");
}
}
答案 0 :(得分:1)
似乎您没有正确设置com.microsoft.tfs.jni.native.base-directory
作为系统属性。
尝试按以下方式设置:
System.setProperty("com.microsoft.tfs.jni.native.base-directory", "C:\Users\userName\native");
或者在命令提示符下设置:
java.exe -D"com.microsoft.tfs.jni.native.base-directory=C:\Users\Username\YourApplication\native"