编辑:有一个相关的问题正在Github上讨论,但在另一种部署模式(Typesafe Activator UI而不是Docker).
我试图模拟系统重启以验证Docker重启策略,该策略声明能够以正确的顺序重新运行容器.
我有一个用Java编写的Play框架应用程序.
Dockerfile看起来像这样:
FROM ubuntu:14.04
#
# [Java8, ...]
#
RUN chmod +x /opt/bin/playapp
CMD ["/bin/bash"]
Run Code Online (Sandbox Code Playgroud)
我开始使用它$ docker run --restart=always -d --name playappcontainer "./opt/bin/playapp".
当我$ service docker stop && service docker restart
然后$ docker attach playappcontainer控制台告诉我:
Play server process ID is 7
This application is already running (Or delete /opt/RUNNING_PID file)
Run Code Online (Sandbox Code Playgroud)
编辑:当我按照Play文档的建议将文件的位置更改为/var/run/play.pid时,结果相同-Dpidfile.path=/var/run/play.pid.
Play server process ID is 7
This application is already …Run Code Online (Sandbox Code Playgroud) java playframework playframework-2.0 docker playframework-2.3
我了解并理解Elasticsearch,Apache Solr和Hibernate Search都基于Apache Lucene库.它们提供快速的全文搜索,所有这些都使用JPA注释,实现JPA和/或定义自定义注释.它们主要用于RDBMS/NoSQL数据存储.索引和可搜索的数据以文档的形式存在.
我完全可以,有人提出Solr vs Hibernate Search的问题- 选择何时以及何时?甚至'Elasticsearch vs Solr'或'Elasticsearch vs Hibernate Search'但是有一个Hibernate Search/Elasticsearch连接器作为一种使用Hibernate Search 和 Elasticsearch 的方法,或者这篇文章询问"如何将Hibernate和Solr集成在一起?" 答案如何将Hibernate Search和Solr集成在一起,这对我来说是不同的,对吧?
假设上述摘要是正确的,并且链接的帖子让我感到困惑:除了Hibernate Search之外,为什么人们会考虑或者使用Elasticsearch或Solr?这不是多余的吗?或者Hibernate Search是否为Solr/Elasticsearch提供了Hibernate ORM不具备的任何接口,因此仅用作某种适配器?
在以下输出中运行命令docker images和docker images -a结果:
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu 14.04 9cbaf023786c 2 days ago 192.8 MB
$ docker images -a
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu 14.04 9cbaf023786c 2 days ago 192.8 MB
<none> <none> 03db2b23cf03 2 days ago 192.8 MB
<none> <none> 8f321fc43180 2 days ago 192.8 MB
<none> <none> 6a459d727ebb 2 days ago 192.8 MB
<none> <none> 2dcbbf65536c 2 days ago 192.8 MB
<none> <none> 97fd97495e49 …Run Code Online (Sandbox Code Playgroud) 我使用 Ruby on Rails 构建了一个 RESTful API,现在只允许经过身份验证的用户发出请求。因此我实现了一个 ApiController:
class ApiController < ApplicationController
include DeviseTokenAuth::Concerns::SetUserByToken
before_action :authenticate_api_v1_user!
end
Run Code Online (Sandbox Code Playgroud)
我使用一个 React 客户端,它会在每个请求中发送所需的身份验证标头。到目前为止一切都运作良好。只是我在模拟请求规范中的登录时遇到问题。
理论上,我会创建一个用户并登录。但是如何将令牌与请求一起发送?
describe 'Items API', type: :request do
# initialize test data
let!(:user) { create(:user) }
let!(:items) { create_list(:item, 10) }
# Test suite for GET /api/v1/items
describe 'GET /api/v1/items' do
# make HTTP get request before each example
before { get '/api/v1/items' }
it 'returns items' do
expect(json).not_to be_empty
expect(json.size).to eq(10)
end
it 'returns status code 200' do
expect(response).to have_http_status(200) …Run Code Online (Sandbox Code Playgroud) 我正在将一个项目从Play 2.2.4迁移到2.4.2,我得到一个我无法理解和解决的异常.
Unexpected exception
ProvisionException: Unable to provision, see the following errors:
1) Error injecting constructor, java.lang.NullPointerException
at controllers.Application.<init>(Application.java:33)
while locating controllers.Application
for parameter 1 at router.Routes.<init>(Routes.scala:36)
while locating router.Routes
while locating play.api.inject.RoutesProvider
while locating play.api.routing.Router
1 error
Run Code Online (Sandbox Code Playgroud)
它发生在我为WS API添加依赖注入之后,如:
public class Application extends Controller {
@Inject
WSClient ws;
WSRequest request = ws.url("https://...");
...
}
Run Code Online (Sandbox Code Playgroud)
该build.sbt文件包含必要的配置
libraryDependencies ++= Seq(
javaJdbc,
cache,
javaWs
)
// Play provides two styles of routers, one expects its actions to be injected, the …Run Code Online (Sandbox Code Playgroud) 在使用 Jest 运行我的测试套件时,我遇到了要求我更新软件包的警告:
npm WARN deprecated jest-dom@2.1.1: jest-dom has moved to @testing-library/jest-dom. Please uninstall jest-dom and install @testing-library/jest-dom instead, or use an older version of jest-dom. Learn more about this change here: https://github.com/testing-library/dom-testing-library/issues/260 Thanks! :)
npm WARN deprecated react-testing-library@5.9.0: react-testing-library has moved to @testing-library/react. Please uninstall react-testing-library and install @testing-library/react instead, or use an older version of react-testing-library. Learn more about this change here: https://github.com/testing-library/dom-testing-library/issues/260 Thanks! :)
Run Code Online (Sandbox Code Playgroud)
在 package.json 我更改了以下内容
"jest-dom": "^2.1.1",
"react-testing-library": "^5.3.0"
Run Code Online (Sandbox Code Playgroud)
到
"@testing-library/jest-dom": "^5.11.1",
"@testing-library/react": "^10.4.7"
Run Code Online (Sandbox Code Playgroud)
当然还有来自的导入语句 …
我正在使用数组来存储文本中特定单词的出现次数.数据格式为word:number.我想通过降低出现次数(即按值)对数组进行排序.有一个简洁的方法吗?或者我应该考虑使用不同的数据结构?
// This is how the array is filled.
var matches = ["word1", "word2", "word2", "word3", "word4", "word4", "word4"];
var count = {};
$.each(matches, function(key, value) {
if(!count[value])
count[value] = 1;
else
count[value]++;
});
Run Code Online (Sandbox Code Playgroud)
在循环之后,这是我得到的并希望按降序值排序:
count = { 'word1':'1', 'word2':'2', 'word3':'1', 'word4':'3' };
Run Code Online (Sandbox Code Playgroud)
我真正希望它看起来像(按值排序):
count = { 'word4':'3', 'word2':'2', 'word1':'1', 'word3':'1' };
Run Code Online (Sandbox Code Playgroud) 我在IntelliJ中运行Play 2.1.2和Solr 4.4.0时收到此错误消息.我以前没有这个,也不明白它的来源.多次尝试清洁项目.在此先感谢您的帮助!
[info] Resolving com.googlecode.concurrentlinkedhashmap#concurrentlinkedhashmap-
[warn] module not found: org.restlet.jee#org.restlet;2.1.1
[warn] ==== local: tried
[warn] [...]\Play212\repository\local\org.restlet.jee\org.restlet\2.1.1\iv
ys\ivy.xml
[warn] ==== Typesafe Releases Repository: tried
[warn] http://repo.typesafe.com/typesafe/releases/org/restlet/jee/org.restlet/
2.1.1/org.restlet-2.1.1.pom
[warn] ==== Typesafe Snapshots Repository: tried
[warn] http://repo.typesafe.com/typesafe/snapshots/org/restlet/jee/org.restlet
/2.1.1/org.restlet-2.1.1.pom
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/org/restlet/jee/org.restlet/2.1.1/org.res
tlet-2.1.1.pom
[warn] module not found: org.restlet.jee#org.restlet.ext.servlet;2.1.1
[warn] ==== local: tried
[warn] [...]\Play212\repository\local\org.restlet.jee\org.restlet.ext.serv
let\2.1.1\ivys\ivy.xml
[warn] ==== Typesafe Releases Repository: tried
[warn] http://repo.typesafe.com/typesafe/releases/org/restlet/jee/org.restlet.
ext.servlet/2.1.1/org.restlet.ext.servlet-2.1.1.pom
[warn] ==== Typesafe Snapshots Repository: tried
[warn] http://repo.typesafe.com/typesafe/snapshots/org/restlet/jee/org.restlet
.ext.servlet/2.1.1/org.restlet.ext.servlet-2.1.1.pom
[warn] ==== public: tried
[warn] http://repo1.maven.org/maven2/org/restlet/jee/org.restlet.ext.servlet/2
.1.1/org.restlet.ext.servlet-2.1.1.pom …Run Code Online (Sandbox Code Playgroud) 我正在关注有关如何使用 Gatsby 实现 Contentful 的 RichText 字段类型的文档。
我的 GraphQL 查询只返回rawRichText 字段上的一个字段,名为synopsis:
query MyQuery {
allContentfulCountry {
edges {
node {
id
synopsis {
raw
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
它返回:
{
"data": {
"allContentfulCountry": {
"edges": [
{
"node": {
"id": "fa07b3db-6acb-5b9a-7c4b-c42ef3c191b0",
"synopsis": {
"raw": "{\"data\":{},\"content\":[{\"data\":{},\"content\":[{\"data\":{},\"marks\":[],\"value\":\"The actual rich text...\",\"nodeType\":\"text\"}],\"nodeType\":\"paragraph\"}],\"nodeType\":\"document\"}"
},
"slug": "france"
}
}
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
文档假设documentToReactComponents(node.bodyRichText.json, options)但我无法访问json并且需要这样做:JSON.parse(country.synopsis.raw)
我错过了什么吗?
"@contentful/rich-text-react-renderer": "^14.1.2",
"@contentful/rich-text-types": "^14.1.2",
System:
OS: macOS 11.0.1 …Run Code Online (Sandbox Code Playgroud)