小编Pau*_*yer的帖子

使用Cypher添加与现有节点的关系

我是第一次尝试Neo4j.我正在使用2.0-RC1社区版.

我创建了一些节点:

MERGE (u:User{username:'admin',password:'admin'})
MERGE (r1:Role{name:'ROLE_ADMIN'})
MERGE (r2:Role{name:'ROLE_WEB_USER'})
MERGE (r3:Role{name:'ROLE_REST_USER'})
Run Code Online (Sandbox Code Playgroud)

现在我想在节点之间添加关系.不过,我希望清除上面的脚本创建的现有数据库,添加语句,并再次运行它.我想添加与现有节点的关系.谷歌帮我找到了这个:

START n=node(*), m=node(*)  
where has(n.username) and has(m.name) and n.username = 'admin' 
and m.name = 'ROLE_WEB_USER' 
create (n)-[:HAS_ROLE]->(m)
Run Code Online (Sandbox Code Playgroud)

哪个工作正常(即使我不懂所有的语法).但是,我知道这会找到任何具有username属性的节点和任何具有name属性的节点,而不是使用标签来检查它是否具有正确的节点类型.

如何使用标签做同样的事情?

neo4j cypher

42
推荐指数
2
解决办法
6万
查看次数

嵌入式Tomcat 7与Tomcat 6相比较慢

我最近开始嵌入Tomcat 7用于我的集成测试,而不是Tomcat 6,因为我需要7个功能中的一些,它是我们的目标容器.与Tomcat 6嵌入式相比,性能非常慢.启动服务器大约需要20秒.这是我正在使用的代码:

Tomcat tomcat = new Tomcat();
tomcat.setPort(port);
tomcat.setSilent(true);

tomcat.setBaseDir(".");
tomcat.getHost().setAppBase(webappDir);

tomcat.addWebapp(context, "");    
tomcat.start();
Run Code Online (Sandbox Code Playgroud)

有没有其他人经历过这个或者有提高性能的建议?我在Windows 7,Linux Mint和Ubuntu上运行测试.

java tomcat tomcat7

10
推荐指数
2
解决办法
3460
查看次数

"没有关于每次测试覆盖率的信息." 来自Sonar与Jacoco Ant构建

我正在使用Ant,Jacoco和Sonar.当我运行我的构建时,Sonar告诉我"没有关于每次测试覆盖率的信息." 并且Sonar仪表板具有我的覆盖结果,但我无法深入查看它们以查看代码.但是,Jacoco生成的HTML报告确实包含深入到代码中.这是我的承保任务:

    <jacoco:coverage destfile="${coverage.output.file}" >
        <junit printsummary="on" 
            errorProperty="test.failed" 
            failureProperty="test.failed" 
            haltonfailure="yes" 
            fork="true">
            <formatter type="brief" usefile="false" />
            <formatter type="xml" />
            <classpath>
                <path refid="test.build.class.path"/>
                <pathelement location="${test.bin.dir}"/>       
            </classpath>
            <batchtest todir="${results.dir}">
                <fileset dir="${test.bin.dir}">
                    <include name = "**/**/*Test.class"/>
                </fileset>
            </batchtest>
        </junit>
    </jacoco:coverage>  

    <jacoco:report>
        <executiondata>
            <file file="${coverage.output.file}"/>
        </executiondata>
        <structure name="${ant.project.name}">
            <classfiles>
                <fileset dir="${bin.dir}"/>
            </classfiles>
            <sourcefiles encoding="UTF-8">
                <fileset dir="${src.dir}"/>
            </sourcefiles>
        </structure>
        <html destdir="${coverage.results.dir}"/>
    </jacoco:report>
</target>
Run Code Online (Sandbox Code Playgroud)

我的声纳目标看起来像这样:

<target name="sonar" depends = "run">
    <property name="sonar.jdbc.url" value="..." />
    <property name="sonar.jdbc.username" value="...r" />
    <property name="sonar.jdbc.password" value="..." />

    <property name="sonar.projectKey" value="org.codehaus.sonar:example-java-ant" />
    <property …
Run Code Online (Sandbox Code Playgroud)

java ant junit jacoco sonarqube

10
推荐指数
1
解决办法
1万
查看次数

如何创建Solr 6内核?

我在数字海洋ubuntu实例上安装了Solr 6:

install_solr_service.sh solr-6.1.0.tgz
Run Code Online (Sandbox Code Playgroud)

并验证Solr正在运行.但是,我无法通过UI或命令行创建任何内核.我尝试了各种不同的排列:

sudo ./solr create -c netest
Run Code Online (Sandbox Code Playgroud)

包含

sudo ./solr create -c netest -d /opt/solr/server/solr/configsets/basic_configs/conf/
Run Code Online (Sandbox Code Playgroud)

但它总是给我:

ERROR: Error CREATEing SolrCore 'netest': Unable to create core [netest] Caused by: /var/solr/data/netest/data
Run Code Online (Sandbox Code Playgroud)

如果我提前创建目录:

sudo mkdir /var/solr/data/netest/
sudo mkdir /var/solr/data/netest/data
sudo chown -R solr:solr /var/solr/data
Run Code Online (Sandbox Code Playgroud)

当我重新运行create命令时,我得到:

错误:错误创建SolrCore'netest':无法创建核心[netest]引起:无法在类路径中找到资源'solrconfig.xml'或'/ var/solr/data/netest'

如果我复制solrconfig.xml到目录并再次运行命令,我得到:

错误:错误创建SolrCore'netest':无法创建核心[netest]引起:无法在类路径中找到资源'schema.xml'或'/ var/solr/data/netest'

而且我在这个阶段陷入困境,因为谷歌没有帮我找到从哪里获取或创建schema.xml文件.

有人可以帮忙吗?

linux solr solr6

9
推荐指数
2
解决办法
2万
查看次数

如何通过私有 NuGet 服务器使用 API 密钥进行 dotnet Restore

我创建了一个私有 NuGet 服务器(https://github.com/ai-traders/liget),它需要 API 密钥来上传包,但不需要下载/恢复它们。

我确信我可以增强服务器的代码以在恢复时强制使用 API 密钥,但我所做的调查(主要是谷歌搜索)尚未提供任何有关如何指定 API 密钥dotnet restore以及Visual Studio NuGet UI 似乎不允许这样做。

有没有办法为 dotnet 恢复指定 API 密钥,或者是将其作为查询参数包含的唯一选项(例如https://mynuget.com?apikey= <API_KEY>)?理想情况下,我想将 API 密钥放在标头中。

nuget-server .net-core dotnet-restore

8
推荐指数
1
解决办法
9345
查看次数

一次从一个zip文件中读取CSV

我有一个具有文件上传功能的Spring MVC应用程序.文件作为MultipartFile传递给控制器​​,从中很容易获得InputStream.我正在上传包含CSV的zip文件,我正在努力寻找打开CSV并一次读取一行的方法."读入固定大小缓冲区的网络上有很多例子.我试过这个,但缓冲区不能很好地连接,很快就会失去同步并占用大量内存:

        ZipEntry entry = input.getNextEntry();

        while(entry != null)
        {
            if (entry.getName().matches("Data/CSV/[a-z]{0,1}[a-z]{0,1}.csv"))
            {
                final String fullPath = entry.getName();
                final String filename = fullPath.substring(fullPath.lastIndexOf('/') + 1);

                visitor.startFile(filename);                    

                final StringBuilder fileContent = new StringBuilder();

                final byte[] buffer = new byte[1024];                   

                while (input.read(buffer) > 0)
                    fileContent.append(new String(buffer));

                final String[] lines = fileContent.toString().split("\n");  

                for(String line : lines)
                {
                    final String[] columns = line.split(",");
                    final String postcode = columns[0].replace(" ", "").replace("\"", "");

                    if (columns.length > 3)
                        visitor.location(postcode, "", "");
                }   

                visitor.endFile();                  
            }

            entry = input.getNextEntry(); …
Run Code Online (Sandbox Code Playgroud)

java csv zip

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

如何将Neo4j JSON转换为Java Object

我已经玩了几个星期Neo4j 2.0 RC1.我正在使用Neo4j作为数据库编写Spring Security实现.当我加载用户时,我从Neo4j得到的响应如下所示:

{
    "columns" : [ "username", "password", "accountNonExpired","accountNonLocked", "credentialsNonExpired", "enabled" ],
    "data" : [ [ "admin", "admin", true, false, true, false ]
}
Run Code Online (Sandbox Code Playgroud)

最初只返回用户名密码(两个字符串)和我能够执行此操作的字段:

class Result
{
    private List<String> columns = new ArrayList<String>();

    private List<ArrayList<String>> data = new ArrayList<ArrayList<String>>();

};

ClientRespose resp = webResource.path(path).type(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON).post(ClientResponse.class, body );
String s = response.getEntity(String.class);
Result r = new Gson().fromJson(s, Result.class);
Run Code Online (Sandbox Code Playgroud)

当然,当我添加其他字段(布尔)时,我需要将Result更改为如下所示:

class Result
{
    private List<String> columns = new ArrayList<String>();

    private List<ArrayList<Object>> data = new ArrayList<ArrayList<Object>>();

}; …
Run Code Online (Sandbox Code Playgroud)

java neo4j

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

CallerArgumentExpression 始终为 null

我正在 C# 8 中试验 [CallerArgumentExpression]:

static void Main(string[] args)
{
    try
    {
        Program query = null;
        Argument(query != null, "Ooops");
    }
    catch (Exception e)
    {
        Console.WriteLine(e.Message);
    }
}

public static void Argument(bool condition, string message, [CallerArgumentExpression("condition")] string conditionExpression = null)
{
    if (!condition) throw new ArgumentException(message: message, paramName: conditionExpression);
}
Run Code Online (Sandbox Code Playgroud)

但是,我无法将 的值conditionExpression设为 null 以外的任何值。

我一直在使用这个https://blog.mcilreavy.com/articles/2018-08/caller-argument-expression-attribute和其他一些页面,当然,作为指南很好,但我无法得到让它工作。

c# .net-core c#-8.0

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

Eclipse Luna文件名未在GIT Commit Changes对话框中显示

我最近在Linux Mint上更新了Eclipse Luna标准.似乎有一些错误,我已经设法解决,除了我用Git进行更改.

"提交更改"对话框按预期显示,但文件窗口仅显示没有文件名的文件图标列表.有没有其他人看过这个,知道如何解决它?

我已经尝试升级到最新的eGit,但这没有帮助.

我一直无法在谷歌上找到有这个问题的人.

eclipse git egit

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

如何使用 C# 进行 OAuth 1 Twitter API 调用 (dotnet core 3.1)

我希望能够从 dotnet core API 服务搜索 twitter 句柄。我查看了users/search.json的 twitter 文档,并请求、借用和窃取了我可以从 stackoverflow 等获取的代码示例(见下文),但我得到的只是:

\n\n

{"errors":[{"code":215,"message":"Bad Authentication data."}]}

\n\n

当我执行生成的curl命令时。

\n\n

抱歉,代码有点混乱,但是有人能看出我做错了什么吗?或者更好的是,如果有一个图书馆可以为我做这件事,我一直找不到一个,那就更好了。

\n\n
using Xunit;\nusing System;\nusing System.Linq;\nusing System.Collections.Generic;\nusing OAuth; // OAuth.DotNetCore, 3.0.1\nusing System.IO;\nusing System.Net;\n\nnamespace TwitterLibTest\n{\n    public class BuildHeaderTest\n    {  \n        private static readonly string consumerKey = "...";\n\n        private static readonly string consumerSecret = "...";\n\n        private static readonly string method = "GET";\n\n        private static readonly OAuthSignatureMethod oauthSignatureMethod = OAuthSignatureMethod.HmacSha1;\n\n        private static readonly string oauthVersion = "1.0a";\n\n        [Fact]\n        public void Header()\n        {\n …
Run Code Online (Sandbox Code Playgroud)

c# twitter oauth twitter-oauth .net-core

2
推荐指数
1
解决办法
4050
查看次数

如何使用 Google Maps Flutter 默认显示地图标签

我认为我的问题与这里相同:

Flutter 在 Google 地图小部件中默认显示标记的 infoWindowText

然而,除了指向另一篇文章的链接之外,没有答案,这并不是我想要做的。

当我的地图在我的应用程序中打开时,它会正确显示标记,但我也希望在打开时默认显示所有标签...

在此输入图像描述

正如此处标记之一所示:

在此输入图像描述

我正在创建这样的标记:

 for (Location location in _locations) {
      final locationMarker = Marker(
          markerId: MarkerId(location.id),
          position: LatLng(location.geoY, location.geoX),
          infoWindow: InfoWindow(
            title: location.name,
          ),
          onTap: () => _onTap(location),
          icon: _mapMarkers.icon(location.slug),
          draggable: false);

      markers.add(locationMarker);
    }
Run Code Online (Sandbox Code Playgroud)

然后地图是这样的:

 Widget _map(Set<Marker> markers) => GoogleMap(
        mapType: MapType.normal,
        initialCameraPosition: CameraPosition(target: widget.mapCentre),
        markers: markers,
        ...
        onMapCreated: (controller) => _onMapCreated(controller, markers),
      );
Run Code Online (Sandbox Code Playgroud)

在 _onMapCreated 中,我尝试显示所有标签,但实际上仅显示标记列表中的最后一个:

 _onMapCreated(GoogleMapController controller, Set<Marker> markers) {
    if (mounted) {
      setState(() {
        _controller.complete(controller);
        controller.setMapStyle(_mapStyle);
        for (var marker in markers) …
Run Code Online (Sandbox Code Playgroud)

google-maps flutter google-maps-flutter

2
推荐指数
1
解决办法
8848
查看次数

未解析的 EL 表达式在带有 Spring MVC 的 JSP 页面上显示列表

我正在尝试做一些非常简单的事情。我只想在 Spring MVC 应用程序中的 JSP 页面上显示一个列表。我在谷歌上搜索了很多,有很多例子(包括 Stackoverflow 上的一些),但它对我不起作用。我正在使用 Maven 和 Spring 3.2.4。这些是我的文件:

项目.java

public class Item 
{
    private final String value;

    public Item(String value)
    {
        this.value = value;
    }

    public String getValue()
    {
        return value;
    }
}
Run Code Online (Sandbox Code Playgroud)

主控制器.java

@Controller
public class MainController 
{
    @RequestMapping("/")
    public String home(ModelMap map) 
    {           
    final List<Item> items = new ArrayList<Item>();
        items.add(new Item("Value 1"));
        items.add(new Item("Value 2"));
        items.add(new Item("Value 3"));
        items.add(new Item("Value 5"));     
        map.addAttribute(items);
        return "list";
    }   
}
Run Code Online (Sandbox Code Playgroud)

列表.jsp

<!DOCTYPE html>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> …
Run Code Online (Sandbox Code Playgroud)

java jsp servlets el spring-mvc

0
推荐指数
1
解决办法
3347
查看次数