线程“main”中的异常java.lang.UnsatisfiedLinkError:com.microsoft.tfs.jni.internal.platformmisc.NativePlatformMisc.nativeGetEnvironmentVariable
问题描述:
在连接到tfs时出现以下错误。线程“main”中的异常java.lang.UnsatisfiedLinkError:com.microsoft.tfs.jni.internal.platformmisc.NativePlatformMisc.nativeGetEnvironmentVariable
异常线程 “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");
}
}
答
似乎你没有正确设置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"
@gurchet辛格有你在上面解决问题解?任何更新? –
感谢它现在的工作 –