我试图用Freemarker打印重音字符,但在重音字符的位置,我只得到问号.我已经证实,以下声明成立:
"UTF-8" == Environment.getCurrentEnvironment().getConfiguration().getDefaultEncoding()
Run Code Online (Sandbox Code Playgroud)
我可以很容易地看到,在将变量字符赋予模板之前,它们已正确保存在变量中.
我的freemarker上下文可以在这里找到:https://gist.github.com/1975239
例如,而不是:
Jedine?ný živý koncert, kde nejen, že uslyšíte, ale i uvidíte splynutí metalové kapely s padesáti?lenným orchestrem v?etn?.
Run Code Online (Sandbox Code Playgroud)
我一直在:
Jedine?ný ?ivý koncert, kde nejen, ?e usly?íte, ale i uvidíte splynutí metalové kapely s padesáti?lenným orchestrem v?etn?.
Run Code Online (Sandbox Code Playgroud)
谢谢.
这是对这些问题的跟进:
似乎 kapt 已经发展了,现在它甚至在 Maven 中得到支持。我正在尝试这个(注意配置中的 Lombok 注释处理器):
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>kapt</id>
<goals>
<goal>kapt</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>${project.basedir}/src/main/java</sourceDir>
<sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
</sourceDirs>
<annotationProcessors>
<annotationProcessor>lombok.core.AnnotationProcessor</annotationProcessor>
</annotationProcessors>
</configuration>
</execution>
...
</plugin>
Run Code Online (Sandbox Code Playgroud)
但它似乎仍然没有效果,而且 Lombok@Getter仍然被忽略,如相关问题中所述。
有什么可以做的吗?
我发现了几个类似的问题:
然而,这些似乎无助于找到原因。我可以在重新加载特定页面约 20 次时复制该行为。
MaxRequestsPerChild没有效果。USE_ZEND_ALLOC=0似乎没有效果,问题仍然存在。mod_forensic它显示请求进来。然后没有错误或完成的请求被记录。你能想到发生这种情况的任何原因吗?
编辑1:
我尝试将日志级别设置为跟踪:
https://gist.github.com/knyttl/861e8a0fe5651408df37cd5c3874946b
请求被处理,然后你可以看到:
[Tue Oct 20 08:37:55.825454 2020] [core:trace4] [pid 1] mpm_common.c(536): mpm child 388 (gen 2/slot 4) exited
Run Code Online (Sandbox Code Playgroud)
没有错误也没有响应。
编辑2:
我更新到 php7.4,问题依旧。
我正在与Kotlin一起使用Hibernate,但FetchType.LAZY在@ManyToOne关系方面存在问题。考虑以下内容:
@ManyToOne(fetch = FetchType.LAZY)
open var event: Event?
Run Code Online (Sandbox Code Playgroud)
问题是,当FetchType.LAZY使用时,获取的内容Event将是Event_$$_jvst_...带有此类的JavaassistLazyInitializer。但是该事件永远不会初始化,所有内容都将为null或为空。
FetchType.LAZY被删除,一切正常。open,var以便Event可以正确代理。没有效果。@Entity课程当然open也是。如果open删除了关键字,将不会创建任何代理,因此不会造成延迟。我的猜测是,Hibernate无法轻松代理这些默认的Kotlin getter。有办法解决吗?
我正在尝试创建Spring集成测试,如下所示:
@RunWith(SpringRunner::class)
@ActiveProfiles(profiles = ["Test"])
@ContextConfiguration(locations = ["classpath:**/applicationContext.xml"])
open class SimpleEntityIT {...}
Run Code Online (Sandbox Code Playgroud)
applicationContact.xml包含:
<context:annotation-config/>
<context:spring-configured/>
<context:property-placeholder
ignore-resource-not-found="false"
location="classpath:application${spring.profiles.active}.properties,classpath:application.properties"/>
<context:component-scan base-package="net.goout"/>
Run Code Online (Sandbox Code Playgroud)
applicationContext已加载,但似乎它被忽略了.Bean不是通过组件扫描构建的,而且application.properties完全被忽略,日志中没有提到:
2018-01-26 20:09:26,131 DEBUG Resolved location pattern [classpath:**/applicationContext.xml] to resources []
2018-01-26 20:09:26,132 DEBUG Loaded 0 bean definitions from location pattern [classpath:**/applicationContext.xml]
2018-01-26 20:09:26,167 INFO Refreshing org.springframework.context.support.GenericApplicationContext@aecb35a: startup date [Fri Jan 26 20:09:26 CET 2018]; root of context hierarchy
2018-01-26 20:09:26,167 DEBUG Bean factory for org.springframework.context.support.GenericApplicationContext@aecb35a: org.springframework.beans.factory.support.DefaultListableBeanFactory@20d3d15a: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.annotation.internalPersistenceAnnotationProcessor,org.springframework.context.event.internalEventListenerProcessor,org.springframework.context.event.internalEventListenerFactory]; root of factory hierarchy
2018-01-26 20:09:26,198 DEBUG Creating …Run Code Online (Sandbox Code Playgroud) 我试图将我的apache配置转换为nginx.对于apache,我有以下内容:
<VirtualHost *:443>
ServerName loc.goout.net
<Location />
ProxyPass http://localhost:8080/ retry=0
ProxyPreserveHost On
</Location>
<Location /i/>
ProxyPass https://dev.goout.net/i/ retry=0
ProxyPreserveHost Off
</Location>
...
Run Code Online (Sandbox Code Playgroud)
像这样,如果我取:
https://loc.goout.net/i/user/606456_001_min.jpg
它正确地从以下内容获取内容:
https://dev.goout.net/i/user/606456_001_min.jpg
所以对于nginx我正在尝试这个:
server {
listen 443 ssl;
server_name loc.goout.net;
proxy_buffering off;
proxy_ssl_session_reuse off;
proxy_redirect off;
proxy_set_header Host dev.goout.net;
location /i/ {
proxy_pass https://dev.goout.net:443;
}
Run Code Online (Sandbox Code Playgroud)
但是当我获取内容时,我将永远得到502.
在nginx日志中,我看到以下内容:
[error] 7#7: *5 no live upstreams while connecting to upstream, client: 127.0.0.1, server: loc.goout.net, request: "GET /i/user/606456_001_min.jpg HTTP/1.1", upstream: "https://dev.goout.net/i/user/606456_001_min.jpg", host: "loc.goout.net"
Run Code Online (Sandbox Code Playgroud)
考虑简单的@RestController,返回一个Map:
@GetMapping("/foo")
public ResponseEntity<Map<String, Object>> foo() {
Map<String, Any> map = HashMap<>();
map.put(...);
return ResponseEntity(map, HttpStatus.OK);
}
Run Code Online (Sandbox Code Playgroud)
这很好用,它返回Map作为JSON.
但是,当你curl在终端中的请求时,光标停留在JSON的末尾,不幸的是,使用它时很不舒服.我们之前的实现始终\n在每个JSON的末尾返回.有没有办法让Spring追加\n?
编辑
我试图实现格式化程序:
private inner class MapFormatter : Formatter<Map<*, *>> {
override fun parse(payload: String, locale: Locale): Map<*, *> {
return Gson().fromJson(payload, Map::class)
}
override fun print(payload: Map<*, *>, locale: Locale): String {
return Gson().toJson(payload) + "\n"
}
}
Run Code Online (Sandbox Code Playgroud)
并添加:
override fun addFormatters(registry: FormatterRegistry) {
registry.addFormatter(MapFormatter())
}
Run Code Online (Sandbox Code Playgroud)
不幸的是它永远不会被调用,我猜格式化程序是用于别的东西.
我在 Google 计算引擎的 VM 中有一个 PerconaDB 实例。旁边是运行 Kubernetes 集群,其中服务连接到 PerconaDB。
当我使用 MySQL 客户端登录并执行时show processlist;,我看到以下内容:
| 175 | user | 10.12.142.24:46124 | user | Sleep | 14 | | NULL | 0 | 0 |
| 176 | user | 10.12.142.24:46126 | user | Sleep | 14 | | NULL | 0 | 0 |
| 177 | user | 10.12.122.42:60806 | user | Sleep | 2 | | NULL | 0 | 0 | …Run Code Online (Sandbox Code Playgroud) dns google-compute-engine kubernetes google-kubernetes-engine
我们有一个包含多个VM实例和Kubernetes集群的Google Cloud项目.
我能够轻松访问Kubernetes服务,kubefwd我可以ping和curl他们一起使用.问题是kubefwd仅适用于Kubernetes,但不适用于其他VM实例.
有没有办法在本地安装网络,所以我可以ping和curl没有它的任何实例具有公共IP和DNS与集群内部相同?
我有一个多项目 gradle.kts 设置,我想重用一个函数,例如。
fun doSomethingWithString(string: String) { return string }
Run Code Online (Sandbox Code Playgroud)
然后我在dependencies {}块中使用该函数。
我想:
fun在根内定义build.gradle.ktsfun在我可以在每个子项目中导入的其他文件中定义这可行吗?
java ×2
kotlin ×2
kubernetes ×2
apache ×1
dns ×1
docker ×1
freemarker ×1
gcloud ×1
gradle ×1
hibernate ×1
junit ×1
kapt ×1
lombok ×1
networking ×1
nginx ×1
php-7.3 ×1
spring ×1
spring-mvc ×1
spring-test ×1