tring运行gradle build时出现此错误
我理解它的版本冲突,但不知道如何解决它和哪些
要排除的版本...
gradle依赖树是:
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/Users/i/.gradle/caches/modules-
2/files-2.1/org.slf4j/slf4j-
log4j12/1.6.1/bd245d6746cdd4e6203e976e21d597a46f115802/slf4j-log4j12-
1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in
[jar:file:/C:/Users/i/.gradle/caches/modules-2/files-
2.1/ch.qos.logback/logback-
classic/1.1.3/d90276fff414f06cb375f2057f6778cd63c6082f/logback-classic-
1.1.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an
explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
SLF4J: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class
path, preempting StackOverflowError.
compile - Compile classpath for source set 'main'.
+--- com.google.code.gson:gson:2.2.4
+--- com.fasterxml.jackson.core:jackson-core:2.6.0
+--- com.fasterxml.jackson.core:jackson-databind:2.6.0
| +--- com.fasterxml.jackson.core:jackson-annotations:2.6.0
| \--- com.fasterxml.jackson.core:jackson-core:2.6.0
+--- com.fasterxml.jackson.core:jackson-annotations:2.6.0
+--- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.6.0
| +--- com.fasterxml.jackson.core:jackson-core:2.6.0 …Run Code Online (Sandbox Code Playgroud) 当我的类包含套接字和事件时,如何实现Dispose模式?
它应该是这样的吗?
class MyClass
{
Socket m_ListenerSocket = new Socket();
book m_Disposed=false;
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
private void Dispose(bool isDisposing)
{
if (!m_Disposed)
{
if (isDisposing)
{
if (m_ListenerSocket != null)
{
m_ListenerSocket.Dispose();
innerClass.Notify -= Notify;
}
}
//finalized unmanged code here
m_Disposed = true;
}
}
~MyClass()
{
Dispose(false);
}
}
Run Code Online (Sandbox Code Playgroud)
我很困惑...套接字类是"托管代码c#版本的winSock"?因此,如果用户名为dispose("isDisposing IS为true"),它应该被释放,那么事件处理程序呢?
所以在最终评论部分应该只释放Inptr对象?谢谢.
我在一本书中看到了这个单身人士的推荐(部分代码附件):
public static Singleton GetSingleton()
{
if (s_value != null)
return s_value;
Monitor.Enter(s_lock);
if (s_value == null)
{
Singleton temp = new Singleton();
Interlocked.Exchange(ref s_value, temp);
}
Monitor.Exit(s_lock);
return s_value;
}
Run Code Online (Sandbox Code Playgroud)
我们在第二个if语句块中添加两行代码,而不是只写:
s_value = new Singleton();
Run Code Online (Sandbox Code Playgroud)
这应该处理第二个线程进入方法并查找s_value != null但未初始化的情况.
我的问题是,我们可以只在第二个if块写入:
{
Singleton temp = new Singleton();
s_value = temp; // instead of Interlocked.Exchange(ref s_value, temp);
}
Run Code Online (Sandbox Code Playgroud)
所以现在的功能是:
public static Singleton GetSingleton()
{
if (s_value != null)
return s_value;
Monitor.Enter(s_lock);
if (s_value == null)
{
Singleton temp = new …Run Code Online (Sandbox Code Playgroud) 您能否举例说明如何使用 PowerShell 在出错时返回错误代码 1?
例如处理这种情况:
if ($serviceUserName) {
cmd /c $serviceBinaryFinalPath install -username:$serviceUserName -password:$serviceUserPassword -servicename:"$ServiceName" -displayname:"$serviceDisplayName" -description:"$serviceDescription"
} else {
cmd /c $serviceBinaryFinalPath install --localsystem -servicename:"$ServiceName" -displayname:"$serviceDisplayName" -description:"$serviceDescription"
}
Run Code Online (Sandbox Code Playgroud)