小编amo*_*fis的帖子

使用git发布maven的插件,如果在进程中推送了提交,则会出错

我们使用git repository和maven release插件.在第一个构建步骤中,我们将所有更改提取到本地存储库,然后在下一个中运行mvn release:prepare release:perform.release:prepare更新工作区,更新pom文件中的版本,在存储库中创建标记,运行所有测试,构建jar等.如果没问题,则将本地存储库更改推送到远程更改(更新后的poms和标记创建).

问题在于,当有人同时推动一些变化时,从maven推送失败.错误消息是:

error: failed to push some refs to 'http://<my_repository>'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again.  See the 'Note about
fast-forwards' section of 'git push --help' for details.
Run Code Online (Sandbox Code Playgroud)

有人有类似的问题吗?怎么解决?

git release maven-3 maven maven-release-plugin

7
推荐指数
1
解决办法
1550
查看次数

如何在 multiprocessing.Pool 中运行的函数中使用模拟

在我的代码中,我使用 multiprocessing.Pool 来同时运行一些代码。简化的代码看起来有点像这样:

    class Wrapper():
        session: Session       


        def __init__(self):
            self.session = requests.Session()
            # Session initialization


        def upload_documents(docs):
            with Pool(4) as pool:
                upload_file = partial(self.upload_document)
                pool.starmap(upload_file, documents)

                summary = create_summary(documents)

            self.upload_document(summary)


        def upload_document(doc):
            self.post(doc)


        def post(data):
            self.session.post(self.url, data, other_params)
Run Code Online (Sandbox Code Playgroud)

所以基本上通过 HTTP 发送文档是并行的。现在我想测试这段代码,但无法做到。这是我的测试:

    @patch.object(Session, 'post')
    def test_study_upload(self, post_mock):
        response_mock = Mock()
        post_mock.return_value = response_mock
        response_mock.ok = True

        with Wrapper() as wrapper:
            wrapper.upload_documents(documents)

        mc = post_mock.mock_calls
Run Code Online (Sandbox Code Playgroud)

在调试中我可以检查模拟调用。有一个看起来有效,它是上传摘要的那个,以及一堆诸如call.json()call.__len__()call.__str__()调用。

没有电话上传文件。当我在方法中设置断点时upload_document,我可以看到每个文档都调用一次它,它按预期工作。但是,我无法测试它,因为我无法通过模拟验证此行为。我认为这是因为有许多进程调用同一个模拟,但仍然 - 我该如何解决这个问题?

我使用Python 3.6

python unit-testing mocking python-3.x python-multiprocessing

7
推荐指数
1
解决办法
4668
查看次数

为什么AWS MSK Kafka代理不断断开并重新连接消费者组

我有带有 2 个代理的 AWS MSK Kafka 集群。从日志中我可以看到(在每个经纪人上)他们正在不断地重新平衡。每分钟我都可以在日志中看到:

Preparing to rebalance group amazon.msk.canary.group.broker-1 in state PreparingRebalance with old generation 350887 (__consumer_offsets-21) (reason: Adding new member consumer-amazon.msk.canary.group.broker-1-27058-8aad596f-b00d-428a-abaa-f3a28d714f89 with group instance id None) (kafka.coordinator.group.GroupCoordinator)
Run Code Online (Sandbox Code Playgroud)

25 秒后:

Preparing to rebalance group amazon.msk.canary.group.broker-1 in state PreparingRebalance with old generation 350888 (__consumer_offsets-21) (reason: removing member consumer-amazon.msk.canary.group.broker-1-27058-8aad596f-b00d-428a-abaa-f3a28d714f89 on LeaveGroup) (kafka.coordinator.group.GroupCoordinator)
Run Code Online (Sandbox Code Playgroud)

为什么会出现这种情况?是什么原因造成的?而什么是amazon.msk.canary.group.broker-1消费群体呢?

amazon-web-services apache-kafka aws-msk

7
推荐指数
1
解决办法
3690
查看次数

使用hg4idea插件将bitbucket.org上的私有Mercurial存储库克隆到InetlliJ IDEA中?

我在bitbucket.org上创建了私有存储库.我想从IntelliJ IDEA中使用它.

我选择"从版本控制中退出",并且有带字段Mercurial Repository URLTest Repository按钮的消息框.
我该Mercurial Repository URL怎么办?

我试过了

  • http://bitbucket.org/my_user_name/my_repo_name,
  • https://,和https://my_user_name@bitbucket.org/my_user_name/my_repo_name.

什么都行不通.
当我点击时,Test Repository我总是收到消息"存储库测试失败了".
我认为这是因为没有用户名和密码的字段,但我不能以某种方式输入这些数据?

mercurial intellij-idea

6
推荐指数
1
解决办法
3992
查看次数

在CDI中使用限定符注入String

我想做一件简单的事情.在CDI中注入合格String(或File).

所以我有一个限定符:

@Retention(RetentionPolicy.RUNTIME)
@Target({FIELD,METHOD,PARAMETER,TYPE})
@Qualifier
public @interface FilesRepositoryPath {}
Run Code Online (Sandbox Code Playgroud)

我有一个制片人:

public class FilesRepositoryPathProducer {

  @Produces
  @FilesRepositoryPath
  public String getRepositoryDirectory() {
    return "path.taken.from.configuration";
  }
}
Run Code Online (Sandbox Code Playgroud)

而我正在尝试使用它:

@ApplicationScoped
public class FilesRepository {

  @Inject
  public FilesRepository(@FilesRepositoryPath String filesDirectory) {
    //Do some stuff
  }
}
Run Code Online (Sandbox Code Playgroud)

但是,WELD无法实例化此bean.我得到一个例外:

org.jboss.arquillian.impl.event.FiredEventException: org.jboss.weld.exceptions.UnproxyableResolutionException: WELD-001410 The injection point [field] @Inject private za.co.fnb.commercial.dms.file.FilesRepositoryBeanTest.repo has non-proxyable dependencies
Run Code Online (Sandbox Code Playgroud)

我知道这String是不可原谅的,但为什么WELD想要创建一个代理?它有@Dependent范围,所以AFAIK它不应该创建代理.我怎样才能使它工作?

cdi jboss-weld

6
推荐指数
1
解决办法
1584
查看次数

在CouchDB 1.0中创建用户时出错

我的系统是ubuntu 10.04,我安装了CouchDB 1.0.我可以创建管理员或更多管理员,以管理员身份登录,一切正常.

从CouchDB中的0.11开始,用户的概念不是管理员,并且可以拥有对数据库的细粒度权限.我想创建这样的用户.我打开Futon,我没有登录,然后点击"注册"链接(右下角).然后有关于用户名和密码的问题.当我填写表单并提交表单时,"用户名"字段下会显示很长的错误消息:

注册错误:{gen_server,call,[couch_query_servers,{get_proc,{doc,<<"_ design/_auth">>,{1,[<< 84,165,145,147,156,145,146,42,53,239,238,7,235,44,58,114 >>]} ,{[{<<"language">>,<<"javascript">>},{<<"validate_doc_update">>,<<"\n function(newDoc,oldDoc,userCtx){\n if((oldDoc) && oldDoc.type!=='user')|| newDoc.type!=='user'){\n throw({forbidden:'doc.type必须是user'}); \n} //我们只允许用户文档现在\n \n if(newDoc._deleted === true){\n //允许管理员删除和匹配用户\n //而不检查其他字段\n if((userCtx.roles.indexOf( '_admin')!== -1)|| \n(userCtx.name == oldDoc.name)){\n return; \n} else {\n throw({forbidden:'只有管​​理员可以删除其他用户文档.'}); \n} \n} \n \n if if(!newDoc.name){\n throw({forbidden:'doc.name is required'}); \n} \n \n if(!(newDoc.roles &&(typeof newDoc.roles.length!=='undefined'))){\n throw({forbidden:'doc.roles必须是数组'}); \n } \n \n if(newDoc._id!==('org.couchdb.user:'+ newDoc.name)){\n throw({\n forbidden:'Doc ID必须是org.couchdb格式. user:name'\n}); \n} \n \n if(oldDoc){//验证所有更新\n if(oldDoc.name!== newDoc.name){\n throw({forbidden:'Usernames无法更改.'}); \n} \n} \n \n if(newDoc.password_sha &&!newDoc.salt){\n throw({\n forbidden:'password_sha的用户必须有盐.' + \n'请参见/_utils/script/couch.js,例如代码.'\n}); \n} \n \n …

couchdb

5
推荐指数
2
解决办法
3841
查看次数

AngularJS - 来自transclude范围的访问指令范围

我有一个表格的指令.通常它只是我需要的,但有时我需要添加更多的输入字段.所以我尝试使用transclusion,但它不起作用.

我创建了一个清单来说明:http://plnkr.co/edit/zNOK3SJFXE1PxsvUvPBQ?p = preview

Directive是一个简单的表单,带有输入字段,transclusion和一个帮助测试它的按钮(不包括重要部分):

scope: {
},
transclude: 'element',
template: 
  '<form name="myForm">' +
  '<input type="text" ng-model="data.inDirective"></input>' +
  '<div ng-transclude></div>' +
  '<button ng-click="showData()">show data</button>' +
  '</form>'
Run Code Online (Sandbox Code Playgroud)

在这里,它与翻译一起使用:

<form-as-directive>
  <input type="text" ng-model="data.inTransclude"></input>
</form-as-directive>
Run Code Online (Sandbox Code Playgroud)

我可以以某种方式在转换中使用指令的范围吗?

angularjs angularjs-directive angularjs-scope

5
推荐指数
2
解决办法
2377
查看次数

从扩展类调用时,groovy 中的闭包不能使用私有字段

我有一个 groovy 课程,其中有一个私有字段和一个方法。在该方法中,我调用 http 服务,并在其中传递一个闭包来处理响应。像这样的东西:

class WebUiRestRequestSender {

    private String jSessionIdCookie

    def login(String username, String password) {
        //...
        httpClient.post(
            path: login,
            body: parameters,
            requestContentType : URLENC
        )  { resp, reader ->
            jSessionIdCookie = getSessionCookie(resp)
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

当我创建此类的对象并调用此方法时,一切正常。但是,当我从此类继承并尝试从继承类调用该方法时,出现错误:

groovy.lang.MissingPropertyException: No such property: jSessionIdCookie for class: ResellerWebUiRestRequestSender
Run Code Online (Sandbox Code Playgroud)

这是为什么?为什么超类方法看不到 Groovy 中超类中定义的属性?

groovy inheritance closures

5
推荐指数
1
解决办法
1869
查看次数

JSF.转换h:commandLink显示的值

我将Status对象传递给h:commandLink值.所以它显示在页面上.问题是,显示字符串是

packages.entity.Status@db2674c8.

我为Status注释创建了转换器

@FacesConverter(forClass = Status.class, value = "statusConverter")
Run Code Online (Sandbox Code Playgroud)

但它不起作用.我试着明确地设置它:

<h:commandLink value="#{result.status}" action="/view">
    <f:converter converterId="statusConverter" />
</h:commandLink>
Run Code Online (Sandbox Code Playgroud)

然后我收到一个错误: /search-form.xhtml @57,58 <f:converter> Parent not an instance of ValueHolder: javax.faces.component.html.HtmlCommandLink@53e387f3

这是真的,h:commandLink不是ValueHolder.有没有办法转换价值h:commandLink

jsf jsf-2

4
推荐指数
1
解决办法
6684
查看次数

Git更改分支,但不要更改工作区中的文件

这类似于我的另一个问题(切换到另一个分支而不更改工作区文件)但在那里工作的解决方案现在不起作用.

我需要删除一些很久以前推送到远程主服务器的更改.所以我不想删除master中的提交,但我想更改文件就像这些更改被还原一样.所以我这样做了:

  1. 在掌握时, git branch limits
  2. git checkout limits
  3. git rebase --interactive <commit before the ones I wanted to remove>
  4. 在交互式控制台中,我删除了我想要还原的更改提交

所以现在limits我已经拥有了像我想要的那样的代码.我如何"移动"它掌握?使用limits我希望更改为master分支的代码,但不更改工作空间中的任何文件,因此我可以将更改作为新更改提交到master.

git branch git-branch

4
推荐指数
2
解决办法
4683
查看次数