我对Spring以及亚马逊AWS都很陌生,所以如果我做了一些可怕的错误,我会提前道歉.
当部署到Elastic Beanstalk上时,我似乎无法让我的Spring Boot应用程序以任何方式与AWS服务通信.我一直在这里按照指南尝试正确设置我的项目.
我基本上是把它们提供的代码并尝试从我的项目中运行:
@Component
public class Storage {
@Autowired
private ResourceLoader resourceLoader;
Logger logger = LoggerFactory.getLogger(this.getClass());
public Storage() {
}
public void writeResource() throws IOException {
Resource resource = this.resourceLoader.getResource("s3://server-images/rootFile.log");
WritableResource writableResource = (WritableResource) resource;
try (OutputStream outputStream = writableResource.getOutputStream()) {
outputStream.write("test".getBytes());
}
}
}
Run Code Online (Sandbox Code Playgroud)
超级,看起来很简单.我还设置了我的application.properties文件:
cloud.aws.credentials.accessKey = A******A
cloud.aws.credentials.secretKey = i******K
cloud.aws.credentials.instanceProfile = true
cloud.aws.region.auto = true
Run Code Online (Sandbox Code Playgroud)
所以我在配置文件中设置密钥和密钥,然后最后,我将这些内容添加到build.gradle文件中以获取Spring Cloud的内容:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.4.RELEASE")
classpath("io.spring.gradle:dependency-management-plugin:0.5.2.RELEASE")
}
}
apply plugin: 'java'
apply …Run Code Online (Sandbox Code Playgroud) 这可能是一个非常简单的问题,但我已经坚持了几个小时......
我正在尝试将亚马逊云集成添加到我的项目中,但我似乎无法让项目识别 jar 文件。我目前只是想实例化一个 AmazonS3 客户端:
AmazonS3 s3 = new AmazonS3Client();
Run Code Online (Sandbox Code Playgroud)
我已将此添加到我的 build.gradle 下的依赖项{ }:
compile('com.amazonaws:aws-java-sdk:1.10.6')
Run Code Online (Sandbox Code Playgroud)
当我运行 gradle build 时,它看起来像是从 maven 下载一堆 jar 文件,但是当我去编译我的项目时,我收到“找不到符号”错误。
error: cannot find symbol
AmazonS3 s3 = new AmazonS3Client();
^
Run Code Online (Sandbox Code Playgroud)
似乎 gradle 没有将类添加到我的类路径或其他东西中。有我需要的插件吗?我需要手动将 jars 添加到我的项目中吗?
谢谢
编辑:我正在使用 IntelliJ Idea 来管理项目。
我目前正试图通过一些小的配置更改来启动和运行Spring Boot应用程序,但我似乎无法让端口正确监听.似乎tomcat实例加载的server.xml会覆盖我的application.properties文件指定的任何内容.
application.properties:
logging.level.app = TRACE
logging.file = /tmp/my-server.log
server.port = 8081
Run Code Online (Sandbox Code Playgroud)
当我将其部署到我的/ usr/local/tomcat/webapps时,我可以访问服务器,但只能访问端口8080.它似乎忽略了server.port属性.我相信服务器正在正确地获取属性文件,因为日志记录正确地转到/tmp/my-server.log
最终目标是让服务器在Amazon Elastic Beanstalk中运行时监听我选择的端口.我可以更新负载均衡器上的端口,但是如果服务器只监听它的预配置端口,那也没关系.
提前感谢您的帮助!
OSX Yosemite,Tomcat 8.0.24,Spring Boot v1.2.4
我正在阅读Kotlin的协程文档,并且在完成本示例之前一直很好。我很难理解它在找到质数时如何进行计算,特别是如何返回filter函数的返回值并将其分配给cur,以及如何从numbersFrom方法中生成数字。
我添加了调试语句来尝试跟踪正在运行的各种协程,但是当启动新协程并从其他协程接收编号时,我仍然迷失在逻辑流程上。
代码:
fun log(msg: String) = println("[${Thread.currentThread().name}] $msg")
fun main(args: Array<String>) = runBlocking<Unit> {
var cur = numbersFrom(context, 2)
for (i in 1..10) {
val prime = cur.receive()
println(prime)
cur = filter(context, cur, prime)
}
}
fun numbersFrom(context: CoroutineContext, start: Int) = produce<Int>(context) {
var x = start
while (true) {
log("NumbersFrom Send: ${x}")
send(x++)
} // infinite stream of integers from start
}
fun filter(context: CoroutineContext, numbers: ReceiveChannel<Int>, prime: Int) = …Run Code Online (Sandbox Code Playgroud) 关于将外部jar添加到android项目和ant项目中似乎有相当多的问题,但我找不到在这种情况下有效的解决方案.我对Ant不太熟悉,这可能会激怒这个问题.
问题是:我正在尝试将JSch库添加到我的uiautomator项目中.我将jsch.jar文件放入/ libs文件夹中,希望它可以通过'android create uitest-project'找到.然而,事实并非如此 - 所以我似乎需要修改build.xml/ant.properties/build.properties或者其他什么来获取ant以找到jar
具体错误是:
[javac] Compiling 5 source files to /Users/.../KeyEvents/bin/classes
[javac] /Users/.../KeyEvents/src/com/proj/automation/core/coreSSH.java:9: error: package com.jcraft.jsch does not exist
Run Code Online (Sandbox Code Playgroud)
build.xml是由android脚本创建的,Ant是开箱即用的 - 所以我认为我的蚂蚁知识是问题:P.
我无法弄清楚为什么AFNetworking 2.0会抛出这条消息.我的理解是application/json是默认的序列化方案,所以如果服务器返回带有content-type:application/json的JSON,为什么AFNetworking会抛出这个错误?
Failure with messages Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: application/json" UserInfo=0x17e2ed60 {com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x17e84100> { URL: http://XXX/XXX/XXX } { status code: 200, headers {
Connection = "keep-alive";
"Content-Type" = "application/json;charset=UTF-8";
Date = "Fri, 14 Aug 2015 16:16:52 GMT";
Server = "Apache-Coyote/1.1";
"Transfer-Encoding" = Identity;
"X-Application-Context" = application;
} }, NSErrorFailingURLKey=http://XXX/XXX/XXX, NSLocalizedDescription=Request failed: unacceptable content-type: application/json, com.alamofire.serialization.response.error.data=<7b227374 61747573 223a3230 302c2263 6f646522 3a225636 594d227d>}
Run Code Online (Sandbox Code Playgroud)
在代码块中注释掉带有X的URL.这有时只会发生,并导致请求失败.如果我发出另一个请求,它会成功.
我正在使用AFHTTPSessionManager单例来发出所有请求.
java ×3
amazon-s3 ×2
gradle ×2
spring ×2
spring-boot ×2
afnetworking ×1
android ×1
iphone ×1
jsch ×1
kotlin ×1
objective-c ×1
tomcat ×1