我继承了一个孤立的Java 8 / Maven项目,并试图确定其构建方式。在自述文件中,我看到了运行以下命令的说明:
mvn -o -q -Dexec.executable="echo" -Dexec.args='${project.version}' org.codehaus.mojo:exec-maven-plugin:exec
Run Code Online (Sandbox Code Playgroud)
当我从我的项目根目录(包含pom.xml)运行该表单时,出现以下错误:
[ERROR] Error resolving version for plugin 'org.codehaus.mojo:exec-maven-plugin' from the repositories [local (/Users/myuser/.m2/repository), central (https://repo.maven.apache.org/maven2)]: Plugin not found in any plugin repository -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the …Run Code Online (Sandbox Code Playgroud) 我正在努力拓宽我的Java视野并开始实际编写Java 8+代码.我有一个情况,我有一个POJO列表(每个POJO实例都有一个id : Long字段),我需要生成一个List<Long>代表他们所有的ids.这是我的代码完美无缺:
List<Fizzbuzz> fizzbuzzes = getFizzbuzzes();
List<Long> fbIds = new ArrayList<>();
for(Fizzbuzz fb : fizzbuzzes) {
fbIds.add(fb.getId());
}
Run Code Online (Sandbox Code Playgroud)
我想知道是否有更"现代"的Java 8+方式(lambdas或集合技巧,流媒体等)来编写这段代码.任何想法还是这样的好事?
这里是 Spring Boot RESTful Web 服务和 Swagger 2。我有以下@Configuration类设置来为我的服务配置 Swagger:
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
}
Run Code Online (Sandbox Code Playgroud)
我启动我的服务,然后转到http://localhost:8080/v2/api-docs(Swagger 的服务来源),然后将该 JSON 粘贴到jsonlint.com,我看到 Spring Boot 自动添加大约 40 个端点,我不希望Swagger 记录这些端点。像/trace端点、 and /health、/envand/beans等东西。这些都是 Spring Boot Actuator 创建的东西,但我不想将其包含在我的公共 API 文档中。
有没有办法将 Swagger 配置为不记录这些框架级端点?
我正在尝试使用 Gradle Maven Publish Plugin将我的 Java 库的快照版本发布到我的本地 Maven 存储库,以便:
1.0.0.SNAPSHOT-<timestamp>,这里<timestamp>是米利斯(类似的东西当前系统时间一样 System.currentTimeInMillis()); 和到目前为止我最好的尝试:
plugins {
id 'java-library'
id 'maven-publish'
}
dependencies {
compile(
'org.hibernate:hibernate-core:5.0.12.Final'
,'com.fasterxml.jackson.core:jackson-core:2.8.10'
,'com.fasterxml.jackson.core:jackson-databind:2.8.10'
,'com.fasterxml.jackson.core:jackson-annotations:2.8.0'
)
testCompile(
'junit:junit:4.12'
)
}
repositories {
jcenter()
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
group 'com.me'
jar {
baseName = 'my-lib'
version = '1.0.0-SNAPSHOT'
}
publishing {
publications {
mavenJava(MavenPublication) { …Run Code Online (Sandbox Code Playgroud) 甲骨文在这里。我有下表:
create table Foobars (
id integer constraint pkFoobars primary key using index,
fizz varchar2(20 char),
buzz varchar2(20 char)
)
Run Code Online (Sandbox Code Playgroud)
在我的代码中,将给我一个名为的字符串fizzOrBuzz,并且我不知道它将在哪个字段(fizz或buzz)之前。我需要搜索Foobars表,要么匹配fizz或buzz基于的fizzOrBuzz价值。唯一可以确定的是没有重复项(没有2个记录的fizz值相同,也没有2个记录的buzz值相同)。
到目前为止,我的查询:
SELECT
id
FROM
Foobars
WHERE EXISTS (
SELECT
id
FROM
Foobars
WHERE
fizz = ? -- fizzOrBuzz gets injected here by the app layer
) OR (
SELECT
id
FROM
Foobars
WHERE
buzz = ? -- fizzOrBuzz gets …Run Code Online (Sandbox Code Playgroud) 我有一个 bash 脚本:
#! /bin/bash
someId=$(curl -sk -H -X POST -d "fizzbuzz" "https://someapi.example.com/v1/orders/fire" | jq '.someId')
if [ -z "$someId" ]; then
echo "Order Placement failed; unable to parse someId from the response"
exit 1
fi
echo "...order $someId placed"
Run Code Online (Sandbox Code Playgroud)
当我运行它时,我得到以下输出:
...order null placed
Run Code Online (Sandbox Code Playgroud)
所以不知怎的$someId,null但是……我不应该看到"Order Placement failed; unable to parse someId from the response"回声吗?
如何修改条件以在为空时if [ -z "$someId" ]; then执行?$someId
我有以下 Go 代码:
now := time.Now().UTC().String()
log.Info("time is: " + now)
Run Code Online (Sandbox Code Playgroud)
运行时会打印出:
time is: 2020-08-21 10:34:43.3547088 +0000 UTC
Run Code Online (Sandbox Code Playgroud)
我只想要 HH:mm:ss 的时间精度,这样它就会打印出来:
time is: 2020-08-21 10:34:43Z
Run Code Online (Sandbox Code Playgroud)
我需要更改什么才能正确格式化我的时间?末尾必须包含“Z”。
我看到这个问题,但获得最多支持的答案是使用一些基于 Akamai 的配置,而我不使用 Akamai 托管它。
我有一个 React/Nextjs,其package.json外观scripts如下:
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"export": "next export"
},
Run Code Online (Sandbox Code Playgroud)
当我跑步时:
npm run export
Run Code Online (Sandbox Code Playgroud)
我得到:
> myapp-website@0.1.0 export
> next export
info - using build directory: /Users/myuser/workspace/myappsite/myapp-website/.next
info - Copying "static build" directory
info - No "exportPathMap" found in "/Users/myuser/workspace/myappsite/myapp-website/next.config.js". Generating map from "./pages"
Error: Image Optimization using Next.js' default loader is not compatible with `next export`.
Possible solutions: …Run Code Online (Sandbox Code Playgroud) 在Scala,Spark和许多其他"大数据"类型的框架,语言,库中,我看到了名为" zip*"的方法.例如,在Scala中,List类型有一个固有的zipWithIndex方法,您可以这样使用:
val listOfNames : List[String] = getSomehow()
for((name,i) <- listOfNames.zipWithIndex) {
println(s"Names #${i+1}: ${name}")
}
Run Code Online (Sandbox Code Playgroud)
同样星火有RDD类似的方法zip,zipPartitions等等.
但方法名称"zip"完全让我失望.这是计算或离散数学的概念吗?!所有这些方法的名称中都有" zip " 的动机是什么?
这是我用于重现确切问题的GitHub 存储库。
不确定这是 Spring Boot 问题还是 Mockito 问题。
我有以下 Spring Boot@Component类:
@Component
class StartupListener implements ApplicationListener<ContextRefreshedEvent>, KernelConstants {
@Autowired
private Fizz fizz;
@Autowired
private Buzz buzz;
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
// Do stuff involving 'fizz' and 'buzz'
}
}
Run Code Online (Sandbox Code Playgroud)
SoStartupListener没有构造函数,并且故意是一个 Spring @Component,它通过@Autowired.
@Configuration提供这些依赖项的类在这里,作为一个很好的衡量标准:
@Configuration
public class MyAppConfiguration {
@Bean
public Fizz fizz() {
return new Fizz("OF COURSE");
}
@Bean
public Buzz buzz() {
return new Buzz(1, true, Foo.Bar); …Run Code Online (Sandbox Code Playgroud) java ×4
spring-boot ×2
apache-spark ×1
bash ×1
collections ×1
go ×1
gradle ×1
java-8 ×1
java-stream ×1
jq ×1
junit ×1
lambda ×1
maven ×1
maven-plugin ×1
mockito ×1
next.js ×1
oracle ×1
reactjs ×1
scala ×1
sql ×1
swagger-2.0 ×1
unit-testing ×1