当我使用继承了ActiveRecord :: Base的User的类型为Staffer的对象时,我得到错误"TypeError:allocator undefined for Proc".
我不确定是什么导致它开始发生的,不幸的是,跟踪提交的提交并不容易.由于系统工作正常,user.rb没有更改,staffer.rb只更改一行以删除未使用的常量.
我在运行rake任务时首先注意到错误,并且从执行此操作的行生成错误:
attributes.slice("id", "email", "state")
Run Code Online (Sandbox Code Playgroud)
进一步的调查表明,这也会引发错误:
puts attributes
Run Code Online (Sandbox Code Playgroud)
这是回溯:
rake aborted!
allocator undefined for Proc
/Users/pupeno/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:227:in `allocate'
/Users/pupeno/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:227:in `revive'
/Users/pupeno/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:183:in `visit_Psych_Nodes_Mapping'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290@watu/gems/delayed_job-3.0.1/lib/delayed/psych_ext.rb:119:in `visit_Psych_Nodes_Mapping_with_class'
/Users/pupeno/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/visitor.rb:7:in `accept'
/Users/pupeno/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:16:in `accept'
/Users/pupeno/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:228:in `block in revive'
/Users/pupeno/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:228:in `map'
/Users/pupeno/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:228:in `revive'
/Users/pupeno/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:183:in `visit_Psych_Nodes_Mapping'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290@watu/gems/delayed_job-3.0.1/lib/delayed/psych_ext.rb:119:in `visit_Psych_Nodes_Mapping_with_class'
/Users/pupeno/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/visitor.rb:7:in `accept'
/Users/pupeno/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:16:in `accept'
/Users/pupeno/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:116:in `block in visit_Psych_Nodes_Sequence'
/Users/pupeno/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:116:in `each'
/Users/pupeno/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:116:in `visit_Psych_Nodes_Sequence'
/Users/pupeno/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/visitor.rb:8:in `accept'
/Users/pupeno/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:16:in `accept'
/Users/pupeno/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:228:in `block in revive'
/Users/pupeno/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:228:in `map'
/Users/pupeno/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:228:in `revive'
/Users/pupeno/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:183:in `visit_Psych_Nodes_Mapping'
/Users/pupeno/.rvm/gems/ruby-1.9.2-p290@watu/gems/delayed_job-3.0.1/lib/delayed/psych_ext.rb:119:in `visit_Psych_Nodes_Mapping_with_class'
/Users/pupeno/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/visitor.rb:7:in `accept'
/Users/pupeno/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:16:in `accept'
/Users/pupeno/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:228:in `block in …Run Code Online (Sandbox Code Playgroud) 我正在尝试将我的库部署到-jdbc-url,但签名失败:
\n\n$ lein release\nOn branch master\nYour branch is ahead of \'origin/master\' by 2 commits.\n (use "git push" to publish your local commits)\nnothing to commit, working directory clean\n[master 23b2409] Version 0.3.0\n 1 file changed, 1 insertion(+), 1 deletion(-)\ngpg: skipped "J. Pablo Fern\xc3\xa1ndez <pupeno@carouselapps.com>": secret key not available\ngpg: signing failed: secret key not available\nerror: gpg failed to sign the data\nerror: unable to sign the tag\nNo credentials found for releases (did you mean `lein deploy clojars`?)\nPassword prompts are not supported when ran …Run Code Online (Sandbox Code Playgroud) 我尝试设置 Heroku Button,我的应用程序需要几个部署后脚本。不知道如何把它放在每个旁边。
这是我的 app.json
{
"name": "App on Heroku",
"description": "The App deployable to Heroku.",
"keywords": [
"App",
"Heroku"
],
"repository": "https://github.com/myaccount/myapp",
"logo": "http://node-js-sample.herokuapp.com/node.svg",
"addons": [
"heroku-postgresql",
"postmark"
],
"scripts": {
"postdeploy": [
"bundle exec rake db:migrate",
"bundle exec rake db:seed",
"bundle exec my_sample:load"
]
}
}
Run Code Online (Sandbox Code Playgroud)
这里的错误信息在
运行脚本和扩展 dynos
部署后退出代码不是 0
bash: ((: bundle exec rake db:migrate,bundle exec rake db:seed,bundle exec my_sample:load: syntax error in expression (error token is "exec rake db:migrate,bundle exec rake db:seed,bundle exec my_sample:load")
Run Code Online (Sandbox Code Playgroud) 如果我从Java的Bouncy Castle中的公共密钥或私有密钥使用getEncoded获取实际密钥(实际类似乎是BCECPublicKey和BCECPrivateKey)。是否可以重构关键对象以在代码中使用它们?
我在这里的Stack Overflow中找到了如何将整个对象序列化为二进制(然后是磁盘),然后再序列化为二进制,再序列化为适当类的对象,但是我相信序列化包含实现细节,如果我尝试使用这些细节,弹跳城堡以外的其他任何键,都会失败。我现在不打算这样做,但是我想对我的程序进行过时的验证。
这就是我创建密钥的方式:
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("EC", "BC");
keyPairGenerator.initialize(new ECGenParameterSpec("secp521r1"), new SecureRandom());
java.security.KeyPair keyPair = keyPairGenerator.generateKeyPair();
privateKey = keyPair.getPrivate();
publicKey = keyPair.getPublic();
Run Code Online (Sandbox Code Playgroud) 我有一个名为的实体User,它通向一个名为的表,该表user在 PostgreSQL 中应该用引号括起来才能工作。我知道我可以指定一个自定义表名,但是 Hibernate 不应该自动做引号吗?
有人告诉我,也许 Hibernate 没有使用 PostgreSQL 方言。当我的数据库配置如下时,这可能吗:
spring.datasource.url = jdbc:postgresql://localhost/database_name
spring.datasource.username = username
spring.datasource.password = password
Run Code Online (Sandbox Code Playgroud)
如果是这种情况,我如何让 Hibernate 使用正确的方言?
我试过:
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect
Run Code Online (Sandbox Code Playgroud)
和
spring.jpa.database=postgresql
Run Code Online (Sandbox Code Playgroud)
和
spring.jpa.database-platform = org.hibernate.dialect.PostgreSQL94Dialect
Run Code Online (Sandbox Code Playgroud)
和
spring.jpa.database=org.hibernate.dialect.PostgreSQLDialect
Run Code Online (Sandbox Code Playgroud)
对错误没有影响:
Hibernate: insert into user (created_at, last_modified_at, account_id, email, hashed_password_salt, name, over_hashed_password, preferred_name, public_key, started_displaying_sites_at, watched_tutorial_at, id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
2017-09-08 14:41:40.177 WARN 15764 --- [ main] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Error: 0, SQLState: 42601 …Run Code Online (Sandbox Code Playgroud) 我正在将 Gradle 项目转换为 Maven,我正在做的一件事是将 Jar 部署到 S3。我已经配置了这样的分布:
<distributionManagement>
<repository>
<id>aws-release</id>
<name>AWS Release Repository</name>
<url>s3://projectx-support/maven2/release</url>
</repository>
<snapshotRepository>
<id>aws-snapshots</id>
<name>AWS Snapshot Repository</name>
<url>s3://projectx-support/maven2/snapshots</url>
</snapshotRepository>
</distributionManagement>
Run Code Online (Sandbox Code Playgroud)
我试过:
<extensions>
<extension>
<groupId>org.springframework.build</groupId>
<artifactId>aws-maven</artifactId>
<version>5.0.0.RELEASE</version>
</extension>
</extensions>
Run Code Online (Sandbox Code Playgroud)
和
<extensions>
<extension>
<groupId>org.kuali.maven.wagons</groupId>
<artifactId>maven-s3-wagon</artifactId>
<version>1.2.1</version>
</extension>
</extensions>
Run Code Online (Sandbox Code Playgroud)
在这两种情况下,我都会遇到相同的错误:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project projectxcommon: Failed to retrieve remote metadata tech.projectx:projectxcommon:1.0.0-SNAPSHOT/maven-metadata.xml: Could not transfer metadata tech.projectx:projectxcommon:1.0.0-SNAPSHOT/maven-metadata.xml from/to aws-snapshots (s3://projectx-support/maven2/snapshots): Unable to load AWS credentials from any provider in the chain -> [Help 1]
Run Code Online (Sandbox Code Playgroud)
在调试模式下运行时,这些是警告/错误:
[DEBUG] …Run Code Online (Sandbox Code Playgroud) 在Kubernetes: Up & Running一书中的“创建部署”部分,它有一个用于部署的 yaml 文件,如下所示:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "1"
Run Code Online (Sandbox Code Playgroud)
设置的意义何在deployment.kubernetes.io/revision: "1"?
这是一个将要应用的文件,而不是查询服务器的结果。
我正在探索使用whitenoise在打包在 Docker 容器中的 Django 应用程序中提供静态文件。在文档中它说:
作为部署应用程序的一部分,您需要运行 ./manage.py collectstatic 以将所有静态文件放入 STATIC_ROOT。(如果您在 Heroku 上运行,那么这会自动为您完成。)
真的需要这样吗?我没有运行./manage.py collectstatic,仍然提供静态文件。
如果不需要,它是一种优化吗?我试图避免在部署过程中出现不必要的步骤。
我正在为一段使用zeep访问SOAP API的代码编写单元测试,所以我想模拟出来.在我的实际代码中,它看起来像这样:
from zeep import Client
def do_something():
client = Client("...")
Run Code Online (Sandbox Code Playgroud)
在我的测试中,我这样做:
from unittest import mock
@mock.patch('zeep.Client')
def test_do_somethi(self, MockedClient):
do_something()
Run Code Online (Sandbox Code Playgroud)
在Client实际功能是获得,是实际ZEEP客户端,而不是我的嘲笑.我也尝试过:
@mock.patch('zeep.client.Client')
Run Code Online (Sandbox Code Playgroud)
结果是一样的.
我也尝试过:
def test_do_something(self):
with mock.patch('zeep.client.Client') as MockedClient:
do_something()
Run Code Online (Sandbox Code Playgroud)
没有区别.
任何想法为什么这不起作用?
java ×2
spring ×2
amazon-s3 ×1
bouncycastle ×1
clojars ×1
clojure ×1
django ×1
gnupg ×1
heroku ×1
hibernate ×1
kubernetes ×1
leiningen ×1
maven ×1
mocking ×1
postgresql ×1
python ×1
spring-boot ×1
springfox ×1
swagger ×1
swagger-ui ×1
testing ×1
whitenoise ×1