我已经开始在线程中学习同步.
同步方法:
public class Counter {
private static int count = 0;
public static synchronized int getCount() {
return count;
}
public synchronized setCount(int count) {
this.count = count;
}
}
Run Code Online (Sandbox Code Playgroud)
同步块:
public class Singleton {
private static volatile Singleton _instance;
public static Singleton getInstance() {
if (_instance == null) {
synchronized(Singleton.class) {
if (_instance == null)
_instance = new Singleton();
}
}
return _instance;
}
}
Run Code Online (Sandbox Code Playgroud)
我什么时候应该使用Synchronized方法和Synchronized块?为什么Synchronized阻止比同步方法更好?
如何从chrome的控制台访问范围变量小部件
function MyCntrl($scope) {
$scope.widgets = [
{text:'Widget #1', datarow:1, datacol:1, datasizex:3, datasizey:3},
{text:'Widget #2', datarow:2, datacol:1, datasizex:3, datasizey:3},
{text:'Widget #3', datarow:1, datacol:2, datasizex:3, datasizey:3},
{text:'Widget #4', datarow:2, datacol:2, datasizex:3, datasizey:3}
];
Run Code Online (Sandbox Code Playgroud)
$scope.widgets简单的东西在控制台中不起作用!
我的问题是如何在docker容器中运行google chrome进行e2e测试.我创建了一个Dockerfile官方Jenkins图像,但是当尝试运行谷歌浏览器时,它会崩溃并显示错误:
Failed to move to new namespace: PID namespaces supported, Network namespace supported, but failed: errno = Operation not permitted
Trace/breakpoint trap (core dumped)
Run Code Online (Sandbox Code Playgroud)
Jenkins docker镜像使用Debian jessie.
我可以用--headless旗帜运行谷歌浏览器,不需要X服务器.
这是我的docker文件:
詹金斯官方形象:
一个人使用来自docker的GUI运行google chrome:
我的第一种方法是使用xvbf,但使用--headlessflag 时过程更简单.
我可以使用相同的安装命令在Ubuntu服务器上运行chrome,但是在docker中它会失败.
在其他意图之后,我使用了--no-sandboxflag,但是docker图像显示了下一个错误.
[0427/180929.595479:WARNING:audio_manager.cc(295)] Multiple instances of AudioManager detected
[0427/180929.595537:WARNING:audio_manager.cc(254)] Multiple instances of AudioManager detected
libudev: udev_has_devtmpfs: name_to_handle_at on /dev: Operation not permitted
Run Code Online (Sandbox Code Playgroud)
其实我运行了这个命令:
google-chrome-stable --headless --disable-gpu --no-sandbox http://www.google.com
我想angular-cli在构建Angular2(打字稿)应用程序时传递自定义参数.这可能吗?如何在我的代码中访问此参数?
场景是这样的:我有一个Angular2有2个布局的应用程序.每种布局都有3种颜色(红色,蓝色,绿色).我想建立所有可能的组合.每个布局和颜色一个应用程序=> layout1red,layout1green,layout2blue,...
我想为每个构建创建6个JSON配置文件,我在其中定义布局和颜色,也许还有一些其他属性.
我有一个Go1.5.1进程/应用程序.当我运行/usr/sbin/lsof -p该过程时,我看到很多"无法识别协议".
monitor_ 13105 root 101u sock 0,6 0t0 16960100 can't identify protocol
monitor_ 13105 root 102u sock 0,6 0t0 21552427 can't identify protocol
monitor_ 13105 root 103u sock 0,6 0t0 17565091 can't identify protocol
monitor_ 13105 root 104u sock 0,6 0t0 18476870 can't identify protocol
Run Code Online (Sandbox Code Playgroud)
proc status/limit/fd
[root@Monitor_q ~]# cat /proc/13105/status
Name: monitor_client
State: S (sleeping)
Tgid: 13105
Pid: 13105
PPid: 13104
TracerPid: 0
Uid: 0 0 0 0
Gid: 0 0 0 0
Utrace: 0
FDSize: …Run Code Online (Sandbox Code Playgroud) 我将使用Spring Boot使用Spring Framework构建我的第一个使用Java的网站,并且它更容易构建它jar,但我有一些关于它的问题.
一般有什么不同?
在jar文件中,视图位于/resources/templates,但在war文件中,它在下面/webapp/WEB-INF/.
有什么区别?我可以jar在在线主机上部署吗?
如何解决此问题.早些时候我的代码正在运行,但IE设置被某人重置.现在我得到了这个例外.
Started InternetExplorerDriver server (32-bit)
2.53.1.0
Listening on port 16183
Only local connections are allowed
Oct 21, 2016 10:14:12 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
Oct 21, 2016 10:14:12 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to straight W3C remote end connection
Oct 21, 2016 10:14:12 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to original OSS JSON Wire Protocol.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities …Run Code Online (Sandbox Code Playgroud) 我想phantomJS用于一些网络测试,我遇到过GhostDriver(https://github.com/detro/ghostdriver).我使用自述文件中的说明构建它,我可以在指定的端口上运行它,但我不知道如何从我的java代码访问Web驱动程序.为了澄清,我在ruby中看到了这个例子:
caps = {
:browserName => "phantomjs",
:platform => "LINUX"
}
urlhub = "http://key:secret@hub.testingbot.com:4444/wd/hub"
client = Selenium::WebDriver::Remote::Http::Default.new
client.timeout = 120
@webdriver = Selenium::WebDriver.for :remote, :url => urlhub, :desired_capabilities => caps, :http_client => client
@webdriver.navigate.to "http://www.google.com/"
puts @webdriver.title
@webdriver.save_screenshot("./screenshot.png")
@webdriver.quit
Run Code Online (Sandbox Code Playgroud)
我只是不确定如何从java做同样的事情.
我正在尝试public static final使用TwiP在Scala中获得Java的真正等价物.
val在a 中创建一个object对我不起作用,因为它是新生成的类的一部分,Example$.class而TwiP无法从类中访问它Example.class.
这是我尝试移植到Scala的Java类的示例:
public static final String[] MY_STRINGS = { "A", "B", "C" };
@Test
public void myTest(@Values("MY_STRINGS") String string) {
...
}
Run Code Online (Sandbox Code Playgroud)
但我不知道如何移植public static final到Scala.如果它是像这里的对象中的val
@RunWith(classOf[TwiP])
class Foo {
import Foo.MY_STRINGS
@Test
def testTwiP(@Values("MY_STRINGS") value: String): Unit = {
println("I'm testing value " + value + ".")
}
}
object Foo {
val MY_STRINGS = Array("A", "B", "C")
}
Run Code Online (Sandbox Code Playgroud)
我只得到以下异常:
net.sf.twip.internal.TwipConfigurationError:
there is …Run Code Online (Sandbox Code Playgroud) 我之前看到了这个问题的一些答案,但我尝试过的解决方案都没有.
我login.css没有login.html在我的Spring Boot应用程序中应用.我也在使用Thymeleaf.
安全性已打开 - 但我不认为这是浏览器中的问题.我没有看到加载失败login.css- 只有消息:
资源解释为样式表但使用MIME类型text/html传输:
浏览器中的进一步检查显示它正在请求text/css,但得到text/html响应.
html:
<!doctype html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity4">
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatiable" content="IE-Edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="Login"/>
<title>LOGIN</title>
<!-- Latest compiled and minified CSS -->
....
<link rel="stylesheet" href="login.css" content-type="text/css"/>
Run Code Online (Sandbox Code Playgroud)
的路径 login.html
\src\main\resources\templates\login.html
Run Code Online (Sandbox Code Playgroud)
的路径 login.css
\src\main\resources\static\login.css
Run Code Online (Sandbox Code Playgroud)
以防万一这是一个权限问题,我把:
.antMatchers("/css/**").permitAll()
Run Code Online (Sandbox Code Playgroud)
我注意到通过CDN提供的所有CSS都没有问题.另外,浏览器返回login.css一个302个状态码.
谢谢
java ×4
spring ×2
spring-boot ×2
angular ×1
angular-cli ×1
angularjs ×1
build-tools ×1
css ×1
docker ×1
e2e-testing ×1
ghostdriver ×1
go ×1
jar ×1
jenkins ×1
phantomjs ×1
scala ×1
sockets ×1
spring-mvc ×1
thymeleaf ×1
typescript ×1
war ×1
webdriver ×1