我正在使用sbt 1.3.9
并且需要更新一些已更改其代码但版本保持不变的库。当我尝试运行sbt update
命令时,没有任何反应,库未下载。我的sbt.build
文件如下所示:
name := """project name"""
organization := "com.example"
version := "1.0-SNAPSHOT"
lazy val root = (project in file(".")).enablePlugins(PlayJava)
lazy val usr = sys.env("MVN_USER")
scalaVersion := "2.13.1"
javacOptions ++= Seq("-source", "11", "-target", "11")
resolvers ++= Seq(
"Jfrog Artifacts".at("https://artifactory.jfrog.com/")
)
credentials += Credentials(
...
)
updateOptions := updateOptions.value.withCachedResolution(false)
updateOptions := updateOptions.value.withLatestSnapshots(false)
libraryDependencies ++= Seq(
guice,
javaWs,
ehcache,
"com.google.api-client" % "google-api-client" % "1.30.7",
"org.apache.commons" % "commons-lang3" % "3.9",
"redis.clients" % "jedis" % "3.2.0"
)
Run Code Online (Sandbox Code Playgroud)
如何清除 …
我使用 docker 来构建我的 Java 应用程序,我使用了多阶段构建,每次运行 docker 命令来构建时都会遇到一些问题 docker 创建带有标签和名称的新中间映像,none
我需要调用中间容器的可能性.
那是我的 dockerfile:
FROM jdk8_201-ubuntu16.04 as java_build
RUN apt-get update && \
apt-get install -y dos2unix
ARG MVN_USER
ARG MVN_PASS
ARG GIT_BRANCH
ARG BUILD_ID
ARG COMMIT_ID
WORKDIR /tmp/app
COPY pom.xml /maven-build/pom.xml
COPY /.mvn/settings.xml /maven-build/settings.xml
COPY mvnw ./mvnw
COPY mvnw.cmd ./mvnw.cmd
COPY /.mvn ./.mvn
RUN chmod +x ./mvnw && \
./mvnw -s /maven-build/settings.xml -B -f /maven-build/pom.xml dependency:resolve dependency:resolve-plugins dependency:go-offline
COPY ./ ./
FROM ubuntu
...
Run Code Online (Sandbox Code Playgroud)
在每个运行docker build
命令之后,我有很多none
图像: …
我有一个比较两个对象的方法,但是我不知道如何通过Jackson库比较JsonNode。
我想要得到这样的东西:
private boolean test(JsonNode source) {
JsonNode test = compiler.process(file);
return test.equals(source);
}
Run Code Online (Sandbox Code Playgroud) 我在异步模式下执行Lua函数,并使用NIOEventLoops。当我尝试获取下一个事件循环并执行Lua函数时,我有一些异常:
com.aerospike.client.AerospikeException$Connection: Error -7 from BB967EF43270008 127.0.0.1 3000: Node BB967EF43270008 127.0.0.1 3000 event loop 5 max connections 100 would be exceeded.
at com.aerospike.client.cluster.Node.getAsyncConnection(Node.java:657) ~[aerospike-client-4.2.2.jar:?]
at com.aerospike.client.async.NioCommand.executeCommand(NioCommand.java:184) [aerospike-client-4.2.2.jar:?]
at com.aerospike.client.async.NioCommand.run(NioCommand.java:146) [aerospike-client-4.2.2.jar:?]
at com.aerospike.client.async.NioEventLoop.registerCommands(NioEventLoop.java:211) [aerospike-client-4.2.2.jar:?]
at com.aerospike.client.async.NioEventLoop.runCommands(NioEventLoop.java:173) [aerospike-client-4.2.2.jar:?]
at com.aerospike.client.async.NioEventLoop.run(NioEventLoop.java:156) [aerospike-client-4.2.2.jar:?]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_181]
Run Code Online (Sandbox Code Playgroud)
那是我获取下一个事件循环的方法:
private synchronized EventLoop getNextEventLoop() {
EventLoop next;
do {
next = eventLoops.next();
} while (next.getProcessSize() >= maxConnectionsPerEventLoop);
return next;
}
Run Code Online (Sandbox Code Playgroud)
这就是我执行Lua函数的方式:
as.execute(getNextEventLoop()
, new ExecuteListener() {
@Override
public void onSuccess(Key key, Object obj) {
...
}
@Override …
Run Code Online (Sandbox Code Playgroud) 我必须User-agent
从用户请求中获取并添加自定义信息User-agent
并将其发回。我有以下控制器:
@RequestMapping("/orders")
@Controller
public class MyController {
@GetMapping("/new_order")
public String newOrder(RedirectAttributes redirectAttributes, Model model) {
if (isUserNotAuthorized()) {
return getLoginRedirectPage(redirectAttributes, "/login");
}
model.addAttribute("order", new Order());
// How to retrieve User-agent and add some custom info and return it back to the user?
return "new_order";
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助!
我需要将application.yml
文件中的数据设置到我的配置类,但是当我尝试这样做时出现错误:
TestConfig is annotated with @ConstructorBinding but it is defined as a regular bean which caused dependency injection to fail.
Run Code Online (Sandbox Code Playgroud)
我的application.yml
文件如下所示:
test:
app:
id: app_id
Run Code Online (Sandbox Code Playgroud)
我的TestConfig
班级是这样的:
@Configuration
@ConfigurationProperties(prefix = "test.app")
@ConstructorBinding
public class TestConfig {
private final String id;
public TestConfig(String id) {
this.id = id;
}
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试这样做,但它对我不起作用。
我哪里错了?
我需要根据类型将 JSON 反序列化为对象。我有以下 JSON:
{
"type": "dog",
"name": "dogName"
}
Run Code Online (Sandbox Code Playgroud)
我有以下课程:
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
@JsonSubTypes({
@JsonSubTypes.Type(value = Dog.class, name = "dog"),
@JsonSubTypes.Type(value = Cat.class, name = "cat"),
})
public abstract class Animal {
@JsonProperty("type")
public String type;
public String name;
}
public class Dog extends Animal {
...
}
public class Cat extends Animal {
...
}
Run Code Online (Sandbox Code Playgroud)
当我尝试反序列化时一切都很顺利:
public class StartPdfApp {
public static void main(String[] args) throws IOException {
...
ObjectMapper mapper = …
Run Code Online (Sandbox Code Playgroud) 我需要转换List
的POJO
,以Map<Integer, List<MyClass>>
其中的关键是要从价值MyClass
也就是下面的代码如下所示:
public class MyClass {
public int id; // this field value must be key of map.
public String name;
}
public static void main(String... args) {
List<MyClass> lst = new ArrayList();
lst.add(new MyClass(1, "John"));
lst.add(new MyClass(1, "Peter"));
lst.add(new MyClass(2, "Sarah"));
Map<Integer, List<MyClass>> res = lst.collect(..);
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能做到这一点?你能帮助我吗?
java ×7
jackson ×2
spring ×2
spring-boot ×2
aerospike ×1
collectors ×1
docker ×1
grouping ×1
java-stream ×1
jsonnode ×1
sbt ×1
scala ×1
spring-mvc ×1