我注意到docker的许多entrypoint.sh脚本都是这样的:
#!/bin/bash
set -e
... code ...
exec "$@"
Run Code Online (Sandbox Code Playgroud)
什么是set -e
和exec "$@"
为什么?
我正在创建一个我正在下载文件的应用程序.为此,我从js中的java类得到响应并下载此响应.为此我的java代码是 -
@ApiOperation(value = "",
notes = "")
@Path("/getProjectJSONTODRAW/{implementation}")
@GET
@Timed
public Response getProjectJSONTODRAW(@PathParam("implementation") String implementation) {
File file = new File(path+File.separator+fileName);
InputStream inputStream =null;
String mimeType =null;
if (!file.exists()) {
String errorMessage = "Sorry. The file you are looking for does not exist";
log.info(errorMessage);
}else {
mimeType = URLConnection.guessContentTypeFromName(file.getName());
if (mimeType == null) {
log.info("mimetype is not detectable, will take default for the file "+file.getName());
mimeType = "application/octet-stream";
}
try {
inputStream = new BufferedInputStream(new FileInputStream(file));
} catch (FileNotFoundException …
Run Code Online (Sandbox Code Playgroud) 我有一个基于Spring的项目,因此以编程方式设置了实体管理器,不需要persistence.xml文件列出所有实体。
我目前正在使用加载时间编织,但是正在尝试使用Eclipselink和Gradle进行静态编织。我想复制由Maven eclipselink插件执行的操作:
https://github.com/ethlo/eclipselink-maven-plugin
我设置了以下gradle(请注意,这不是Kotlin DSL的常规做法):
task<JavaExec>("performJPAWeaving") {
val compileJava: JavaCompile = tasks.getByName("compileJava") as JavaCompile
dependsOn(compileJava)
val destinationDir = compileJava.destinationDir
println("Statically weaving classes in $destinationDir")
inputs.dir(destinationDir)
outputs.dir(destinationDir)
main = "org.eclipse.persistence.tools.weaving.jpa.StaticWeave"
args = listOf("-persistenceinfo", "src/main/resources", destinationDir.getAbsolutePath(), destinationDir.getAbsolutePath())
classpath = configurations.getByName("compile")
}
Run Code Online (Sandbox Code Playgroud)
当我尝试运行任务时,编织任务失败,因为它正在寻找不存在的persistence.xml。
有什么方法可以在基于Spring的JPA项目中静态编织JPA实体?
Exception Description: An exception was thrown while processing persistence.xml from URL: file:/home/blabla/trunk/my-module/src/main/resources/
Internal Exception: java.net.MalformedURLException
at org.eclipse.persistence.exceptions.PersistenceUnitLoadingException.exceptionProcessingPersistenceXML(PersistenceUnitLoadingException.java:117)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processPersistenceXML(PersistenceUnitProcessor.java:579)
at org.eclipse.persistence.internal.jpa.deployment.PersistenceUnitProcessor.processPersistenceArchive(PersistenceUnitProcessor.java:536)
... 6 more
Caused by: java.net.MalformedURLException
at java.net.URL.<init>(URL.java:627)
at java.net.URL.<init>(URL.java:490)
at java.net.URL.<init>(URL.java:439)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(XMLEntityManager.java:620)
at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(XMLVersionDetector.java:148)
at …
Run Code Online (Sandbox Code Playgroud) 如果我有一个 Spring 配置类(即用 @Configuration 注释的类),我可以使用构造函数注入吗?
如果我添加一个,我会得到一个没有默认构造函数的消息,如果我添加一个默认构造函数,它会使用它而不是重载的构造函数,这并没有真正的帮助。
这是我的测试:
@Test
fun `test config properties`() {
mockMvc.request(HttpMethod.GET,"someUrl") {
accept = MediaType.TEXT_PLAIN
}.andExpect {
status { isOk }
content { contentType(MediaType.TEXT_PLAIN) }
}
}
Run Code Online (Sandbox Code Playgroud)
它失败了:
预期:text/plain 实际:text/plain;charset=UTF-8
这是使用适用于 MockMVC 的 Kotlin DSL。
如何更改接受以允许 charset=UTF-8 ?
我和我的团队目前正在开发一个 Android 应用程序来进行快速实时和非实时图像处理。
我们面临两个问题:
首先,我们想将 Bitmap 转换为 Texture 以使用 OpenGL 着色器处理图片,然后将其转换回 Bitmap。我们尝试了一些不成功的实现,例如在 SurfaceTexture 和 Renderer 中使用 GLUtils.texImage2D 函数。
我们的第二个问题是我们目前不知道如何在我们的实时相机活动中保存纹理。我们使用 OnFrameAvailableListener 来处理图像。但就目前而言,我们无法保留原始纹理。
我们希望有人可以为我们的问题提供答案。提前致谢 !
根据Spring Boot gradle 插件参考,我应该能够将特定模式的 jars 打包到特定层(用于制作更好的 docker 文件)。
我对文档中使用的模式匹配感到困惑。下面是一个例子:
tasks.getByName<BootJar>("bootJar") {
layered {
isIncludeLayerTools = true
application {
intoLayer("spring-boot-loader") {
include("org/springframework/boot/loader/**")
}
intoLayer("application")
}
dependencies {
intoLayer("module-dependencies") {
include("com*:*:*")
}
intoLayer("dependencies")
}
layerOrder = listOf("dependencies", "spring-boot-loader", "module-dependencies", "application")
}
}
Run Code Online (Sandbox Code Playgroud)
我不明白的是这种模式匹配匹配的是什么:
intoLayer("module-dependencies") { include("com*: : ") }
它是 jar 的组、工件和版本吗?这是罐子的名字吗?
如果我有一个多模块项目,其中包含模块 aa、ab 和 ac,相当于 aa.jar、ab.jar 和 ac.jar 以及一个外部依赖项 org.something:anartifact:25 相当于 anartifact-25.jar 什么模式我是否需要添加以在一层中包含 aa、ab 和 ac,在另一层中包含所有其他依赖项?
我使用Apache CXF创建了soap服务,我创建了一个@WebService.在该服务中,我需要注入@Service.当我@Autowire服务该实例仍然为null.
端点初始化
@Bean
public Endpoint endpointToken() {
EndpointImpl endpoint = new EndpointImpl(bus, new GenerateLoginToken());
endpoint.publish("/Token");
return endpoint;
}
Run Code Online (Sandbox Code Playgroud)
Serivce Class
@WebService(serviceName = "GenerateToken", portName = "TokenPort",
targetNamespace = "http://service.ws.samp",
endpointInterface = "com.web.sigel.ws.soap.webServices.GenerateToken")
@Service("AuthService")
public class GenerateLoginToken implements GenerateToken {
@Autowired
private AuthService authService; //this remains Null whenever i make a call.
@Override
@RequestWrapper(localName = "loginRequest", targetNamespace = "http://service.ws.samp", className = "com.web.sigel.ws.soap.security.LoginRequest")
public LoginResponse generateToken(LoginRequest loginRequest) {
LoginResponse loginResponse = new LoginResponse();
String token = authService.createAuthToken(loginRequest);
loginResponse.setToken(token);
return loginResponse;
} …
Run Code Online (Sandbox Code Playgroud) spring ×4
java ×2
spring-boot ×2
android ×1
bitmap ×1
blob ×1
constructor ×1
cxf ×1
docker ×1
download ×1
eclipselink ×1
javascript ×1
kotlin ×1
mockmvc ×1
opengl-es ×1
shell ×1
soap ×1
spring-mvc ×1