小编tma*_*wen的帖子

Maven在现有目录中生成achetype

我正在尝试使用现有目录创建空的 Maven Web 项目(实际上来自github项目,它是空的并且只包含自述文件)。

但是 maven 似乎检测到目录存在并且失败并出现错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.2:generate (default-cli) on project standalone-pom: Directory loms already exists - please run from a clean directory -> [Help 1]
Run Code Online (Sandbox Code Playgroud)

有机会强制 maven 使用现有目录吗?

调用命令:

mvn archetype:generate -DgroupId=org.reaver.devs -DartifactId=loms -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false
Run Code Online (Sandbox Code Playgroud)

java pom.xml maven-3 maven maven-archetype

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

Vertx单元测试阻塞主线程

在尝试使用事件总线通过测试类测试Vert.x Verticle时,我遇到了"阻塞错误".这里是垂直和测试类:

EventBusReceiverVerticle:

public class EventBusReceiverVerticle extends AbstractVerticle {

    public EventBusReceiverVerticle(String name) {
        this.name = name;
    }

    public void start() {

              vertx.eventBus().consumer("geo-service", (Message<JsonObject> handler) -> {
            {
                try {
                    System.out.println("sleep 10 seconds");
                    Thread.sleep(10000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }           
            }
        });
    }
}
Run Code Online (Sandbox Code Playgroud)

测试类:

@RunWith(VertxUnitRunner.class)
public class MyFirstVerticleTest {
    Vertx vertx;
    EventBus eb;
    private static final Logger logger = LoggerFactory.getLogger(MyFirstVerticleTest.class);


    @Before
    public void setUp(TestContext context) {
        logger.info("@Before");
        vertx = Vertx.vertx();
        eb = vertx.eventBus();

        Async async = context.async(); …
Run Code Online (Sandbox Code Playgroud)

java vert.x

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

Micronaut:如何映射 HashMap 中的所有属性值?

我一直在为了学习和一个小规模项目而学习 micronaut,但我一直遇到一个问题。

所以假设我在application.yml文件中有这些数据

output:
    -file:
        name: PDF
        size: 50000
    -file:
        name: DOCX
        size: 35000
Run Code Online (Sandbox Code Playgroud)

所以我的目标是将这些精确的数据映射到 HashMap 中,我可以进一步使用它。我希望我的代码具有独立于任何条件的所有数据。如果我添加另一种文件类型,它也应该自动映射该文件类型的数据。简而言之,最后我想要一个Map<name, path> ,其中包含 yaml 中可用的所有值。我尝试过 EachProperty。

https://guides.micronaut.io/micronaut-configuration/guide/index.html#eachProperty 但我必须传递“名称”作为参数。

任何帮助深表感谢。

java dependency-injection microservices micronaut

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

绕过 JAVA_OPTS 中的非代理主机

我正在通过获取门户服务器的 standalone.conf.bat 添加非代理主机

-Dhttp.proxyHost=10.111.1.00 -Dhttp.proxyPort=80 -Dhttp.nonProxyHosts=localhost|127.0.0.1|172.16.31.* "
Run Code Online (Sandbox Code Playgroud)

当我启动服务器时出现以下错误。

c:\jboss-jpp-6.1.0\jboss-jpp-6.1\bin>standalone.bat
Calling "c:\jboss-jpp-6.1.0\jboss-jpp-6.1\bin\standalone.conf.bat"
'127.0.0.1' is not recognized as an internal or external command,
operable program or batch file.
Run Code Online (Sandbox Code Playgroud)

java gatein

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

DBD :: mysql :: st执行失败:MySQL服务器已经消失了

我想将fifo管道中的数据插入到mysql表中

我的脚本如下:

#!/usr/bin/perl
#Script to read data out of a named pipe and write to MySQL database.

$| = 1;

use strict;
use DBI();

my $filename;
my $inputline;
my $linenumber;
my @arr;
$filename = "./SEC_fifo";
open(FIFO, "+< $filename") or die "FIFO error on $filename $!";
my $dbh = DBI->connect("DBI:mysql:database=ecdb;host=localhost",
        "user", "[pwd]",
        {'RaiseError' => 1});
while (<FIFO>)
{
  $inputline = $_;
   @arr = split(/,/,$inputline);

  # Quit read loop when requested.
  last if($inputline =~ /quit/i);

  chop $inputline;
  $linenumber++;
  print "Got: [$inputline], "; …
Run Code Online (Sandbox Code Playgroud)

mysql perl

3
推荐指数
2
解决办法
9305
查看次数

为什么不Reflection.getFieldsAnnotatedWith()返回任何字段?

我遇到了一个问题的思考.我正在尝试Set使用Reflections#getFieldsAnnotatedWith方法得到一个字段,但是当我运行单元测试时,它什么也没有返回,有人可以告诉我为什么吗?(我正在使用IntelliJ IDE)

这是我正在使用的课程,这是非常基础的.

//The test class run with junit

public class ReflectionTestingTest {

    @Test
    public void test() {
        Reflections ref = new Reflections(AnnotatedClass.class);
        assertEquals(2, ref.getFieldsAnnotatedWith(TestAnnotation.class).size());
        Set<Field> fields = ref.getFieldsAnnotatedWith(TestAnnotation.class);
    }
}

//The class with the annotated fields I want to have in my Set.

public class AnnotatedClass {

    @TestAnnotation
    public int annotatedField1 = 123;

    @TestAnnotation
    public String annotatedField2 = "roar";
}

//And the @interface itself

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface TestAnnotation {}
Run Code Online (Sandbox Code Playgroud)

测试失败,并显示以下消息: …

java reflection unit-testing annotations reflections

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

Spring错误-springframework.web.client.HttpClientErrorException:404未找到

我正在尝试使用Spring将对象传递给另一个类(我不确定我使用的是正确的术语,我对Spring来说是个新手):

TestServicesUtils.getTemplate().postForLocation(
     "http://"
     + serverConfig
     + ":"
     + port
     + "/test/rest/TestResultService/insertTestResult/",
    results); 
Run Code Online (Sandbox Code Playgroud)

当我运行程序时,它到达该行并抛出Exception

log4j:WARN No appenders could be found for logger (org.apache.commons.httpclient.HttpClient).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
org.springframework.web.client.HttpClientErrorException: 404 Not Found
        at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:76)
Run Code Online (Sandbox Code Playgroud)

尝试连接的类:

log4j:WARN No appenders could be found for logger (org.apache.commons.httpclient.HttpClient).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
org.springframework.web.client.HttpClientErrorException: 404 Not Found
        at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:76)
Run Code Online (Sandbox Code Playgroud)

路径似乎很好,我不知道为什么找不到该方法。我需要注册路径吗?

java spring weblogic maven

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

了解Action Phase和Render Phase的执行

我正在使用Liferay 6进行门户开发.

通过Liferay开发人员指南,作者解释了Portlet执行有两个阶段

  1. 行动阶段
  2. 渲染阶段
public class DateTimePortlet extends GenericPortlet 
{
    public void doView(RenderRequest req, RenderResponse res) throws IOException, PortletException 
    {        
        Object actionAttribute = req.getAttribute("datetime");
        res.getWriter().println("Date Time:" + (actionAttribute != null ? actionAttribute :"Unavailable"));
        res.getWriter().println("<BR/>");
        PortletURL u = res.createActionURL();
        res.getWriter().println("<A href=" + u + ">Trigger an action.");
        res.getWriter().close();
    }

    public void processAction(ActionRequest req, ActionResponse res) throws PortletException 
    {
        req.setAttribute("datetime",new Date());
    }        
}
Run Code Online (Sandbox Code Playgroud)

我的理解是该doView方法被称为" 渲染阶段 ",该processAction方法被称为" 动作阶段 ".

如果页面上显示5个portlet,doView则会为每个页面刷新执行"渲染阶段"(即" 方法"中的代码).

如果我是对的,请告诉我.

portlet liferay

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

Quarkus Vert.x示例

我想使用以Kotlin编写并使用Vert.x verticles的现有项目测试Docker的Quarkus和本机映像。

您能否指出一个有关如何使用Quarkus部署顶点的示例?

我的依存关系是vertx-sockjs-service-proxyvertx-lang-kotlin

我在Vert.x扩展测试中找到了一些示例,但找不到在服务器启动时如何部署我的顶点的方法。

@Inject
EventBus eventBus;

@Route(path = "/hello-event-bus", methods = GET)
void helloEventBus (RoutingExchange exchange){
    eventBus.send("hello", exchange.getParam("name").orElse("missing"), ar -> {
        if (ar.succeeded()) {
            exchange.ok(ar.result().body().toString());
        } else {
            exchange.serverError().end(ar.cause().getMessage());
        }
    });
}
Run Code Online (Sandbox Code Playgroud)

kotlin vert.x quarkus

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

有没有办法在Springboot中进行提前编译?

我读过有关提前编译的内容,并且有一个Java框架Micronaut可以做到这一点。

我只是想知道是否可以在Spring Boot中做到这一点。

java spring native spring-boot graalvm-native-image

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

如何在spark java中的数据集上应用map函数

我的CSV文件:

YEAR,UTILITY_ID,UTILITY_NAME,OWNERSHIP,STATE_CODE,AMR_METERING_RESIDENTIAL,AMR_METERING_COMMERCIAL,AMR_METERING_INDUSTRIAL,AMR_METERING_TRANS,AMR_METERING_TOTAL,AMI_METERING_RESIDENTIAL,AMI_METERING_COMMERCIAL,AMI_METERING_INDUSTRIAL,AMI_METERING_TRANS,AMI_METERING_TOTAL,ENERGY_SERVED_RESIDENTIAL,ENERGY_SERVED_COMMERCIAL,ENERGY_SERVED_INDUSTRIAL,ENERGY_SERVED_TRANS,ENERGY_SERVED_TOTAL
2011,34,City of Abbeville - (SC),M,SC,880,14,,,894,,,,,,,,,,
2011,84,A & N Electric Coop,C,MD,135,25,,,160,,,,,,,,,,
2011,84,A & N Electric Coop,C,VA,31893,2107,0,,34000,,,,,,,,,,
2011,97,Adams Electric Coop,C,IL,8334,190,,,8524,,,,,0,,,,,0
2011,108,Adams-Columbia Electric Coop,C,WI,33524,1788,709,,36021,,,,,,,,,,
2011,118,Adams Rural Electric Coop, Inc,C,OH,7457,20,,,7477,,,,,,,,,,
2011,122,Village of Arcade,M,NY,3560,498,100,,4158,,,,,,,,,,
2011,155,Agralite Electric Coop,C,MN,4383,227,315,,4925,,,,,,,,,,
Run Code Online (Sandbox Code Playgroud)

在这里下载Spark代码来读取CSV文件:

public class ReadFile8 {

    public static void main(String[] args) throws IOException {

        SparkSession session = new SparkSession.Builder().appName("CsvReader").master("local").getOrCreate();

        //Data taken by Local System
        Dataset<Row> file8Data = session.read().format("com.databricks.spark.csv").option("header", "true").load("file:///home/kumar/Desktop/Eletricaldata/file8_2011.csv");

        // Register the DataFrame as a SQL temporary view
        file8Data.createOrReplaceTempView("EletricalFile8Data");
        file8Data.show();
    } …
Run Code Online (Sandbox Code Playgroud)

java apache-spark apache-spark-sql

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