我有两个码头图像.其中一个docker镜像(来自第一个容器)在运行时会生成一些文件,这些文件需要由另一个容器使用.
我可以这样做吗?
我是WPF的新手.
我正在尝试将字符串集合绑定到组合框.
public ObservableCollection<string> ListString {get; set;}
Run Code Online (Sandbox Code Playgroud)
绑定和datacontext设置如下
<Window
x:Class="Assignment2.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:validators="clr-namespace:Assignment2"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525"
DataContext="{Binding RelativeSource={RelativeSource Self}, Path=.}">
<Grid>
<ComboBox Height="23" HorizontalAlignment="Left" Margin="109,103,0,0" Name="StringComboBox" VerticalAlignment="Top" Width="120" SelectionChanged="StringComboBox_SelectionChanged">
<ComboBox.ItemsSource>
<Binding Path="ListString" BindsDirectlyToSource="True" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged"></Binding>
</ComboBox.ItemsSource>
</ComboBox>
Run Code Online (Sandbox Code Playgroud)
我发现这种情况正在发生,因为集合正在更新.如果我写
public MainWindow()
{
InputString = "";
ListString = new ObservableCollection<string>();
ListString.Add("AAA");
ListString.Add("BBB");
ListString.Add("CCC");
InitializeComponent();
}
Run Code Online (Sandbox Code Playgroud)
它确实有效,但是如果我InitializeComponent()在第一行上面移动如下,则不起作用.
public MainWindow()
{
InitializeComponent();
InputString = "";
ListString = new ObservableCollection<string>();
ListString.Add("AAA");
ListString.Add("BBB");
ListString.Add("CCC");
}
Run Code Online (Sandbox Code Playgroud)
我该怎么办??
我正在编写一个控制器测试,其中控制器看起来像
@RestController
public class VehicleController {
@Autowired
private VehicleService vehicleService = null;
...
}
Run Code Online (Sandbox Code Playgroud)
虽然测试类看起来像
@RunWith(SpringRunner.class)
@WebMvcTest(VehicleController.class)
public class VehicleControllerTest {
@Autowired
private MockMvc mockMvc = null;
@MockBean
private VehicleService vehicleServie = null;
@Test
public void test() {
...
}
}
Run Code Online (Sandbox Code Playgroud)
当我运行此测试时,它失败并出现以下错误
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.example.database.repositories.SomeOtherRepository' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
Run Code Online (Sandbox Code Playgroud)
这里,SomeOtherRepository不在给定的控制器或服务中使用。
如果我这样做@MockBean测试SomeOtherRepository有效,但其余存储库也会出现同样的问题。
@MockBean private SomeOtherRepository someOtherRepository = null
... …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用无服务器框架和 Python 开发一个简单的无服务器应用程序。
这是我的 serverless.yml
service: hello-world
provider:
name: aws
region: us-west-2
runtime: python3.7
environment:
DB_ENDPOINT:
DB_USERNAME:
DB_PASSWORD:
plugins:
- serverless-python-requirements
functions:
hello:
handler: handler.trial_registration
Run Code Online (Sandbox Code Playgroud)
当我运行时出现sls deploy以下错误
Serverless: Generated requirements from /home/ganesh/code/hello-world/requirements.txt in /home/ganesh/code/hello-world/.serverless/requirements.txt...
Serverless: Installing requirements from /home/ganesh/.cache/serverless-python-requirements/5c625dc5f843b3bb1163fd11989b43fb3cbca4299219c6ef399108fb36e56a2f_slspyc/requirements.txt ...
Serverless: Using download cache directory /home/ganesh/.cache/serverless-python-requirements/downloadCacheslspyc
Error --------------------------------------------------
Error: python3.7 not found! Try the pythonBin option.
at pipAcceptsSystem (/home/ganesh/code/hello-world/node_modules/serverless-python-requirements/lib/pip.js:100:13)
at installRequirements (/home/ganesh/code/hello-world/node_modules/serverless-python-requirements/lib/pip.js:168:9)
at installRequirementsIfNeeded (/home/ganesh/code/hello-world/node_modules/serverless-python-requirements/lib/pip.js:532:3)
at ServerlessPythonRequirements.installAllRequirements (/home/ganesh/code/hello-world/node_modules/serverless-python-requirements/lib/pip.js:611:29)
at ServerlessPythonRequirements.tryCatcher (/home/ganesh/code/hello-world/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/home/ganesh/code/hello-world/node_modules/bluebird/js/release/promise.js:517:31)
at Promise._settlePromise (/home/ganesh/code/hello-world/node_modules/bluebird/js/release/promise.js:574:18)
at …Run Code Online (Sandbox Code Playgroud) 冷杉让我明白我不想使用更高级别的API,我只想使用套接字编程
我编写了以下程序,使用POST请求连接到服务器.
import socket
import binascii
host = "localhost"
port = 9000
message = "POST /auth HTTP/1.1\r\n"
parameters = "userName=Ganesh&password=pass\r\n"
contentLength = "Content-Length: " + str(len(parameters))
contentType = "Content-Type: application/x-www-form-urlencoded\r\n"
finalMessage = message + contentLength + contentType + "\r\n"
finalMessage = finalMessage + parameters
finalMessage = binascii.a2b_qp(finalMessage)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
s.sendall(finalMessage)
print(s.recv(1024))
Run Code Online (Sandbox Code Playgroud)
我在线检查了如何创建POST请求.
不知何故Paramters没有传递给服务器.我是否必须在请求之间添加或删除"\ r \n"?
在此先感谢,问候,Ganesh.
我可以使用以下语法创建多行字符串:
string = str("Some chars "
"Some more chars")
Run Code Online (Sandbox Code Playgroud)
这将产生以下字符串:
"Some chars Some more chars"
Run Code Online (Sandbox Code Playgroud)
Python是加入这两个单独的字符串还是编辑器/编译器将它们视为单个字符串?
Ps:我只想了解内部情况.我知道还有其他方法来声明或创建多行字符串.
我有一个 Zuul 网关代理,在那里我检查从用户收到的令牌的授权。现在,当这个请求被传递到其他微服务以获取用户特定的数据时,用户信息需要从网关传递到微服务。
现在,我已经在请求标头中添加了用户 ID,并使用API header注释在相应的微服务控制器中获取它。
这是传递用户信息的正确方法吗?还有其他更好的方法吗?
我有一份基于计时器的工作
@Component
public class Worker {
@Scheduled(fixedDelay = 100)
public void processEnvironmentActions() {
Job job = pickJob();
}
public Job pickJob() {
Job job = jobRepository.findFirstByStatus(Status.NOT_PROCESSED);
job.setStatus(Status.PROCESSING);
jobRepository.save(job);
return job;
}
}
Run Code Online (Sandbox Code Playgroud)
现在,在大多数情况下,这应该给我正确的结果。但是如果有两个微服务实例同时执行这段代码会怎样呢?
我如何确保即使有多个服务实例,存储库也应该始终只为一个实例而不是其他实例提供一项工作。
编辑:我认为人们越来越困惑/专注于@Transactional所以删除它。问题保持不变。
我正在形成一个帖子请求.
mydict = {'key1': 'value@1', 'key2': 'value@2'}
encoded_dict = urllib.urlencode(mydict)
Run Code Online (Sandbox Code Playgroud)
这将导致
key1=value%401&key2=value%402
Run Code Online (Sandbox Code Playgroud)
我真正想要的是
key1=value@1&key2=value@2
Run Code Online (Sandbox Code Playgroud)
还有其他方法吗?
我正在尝试创建一个无服务器项目,该项目将部署CloudFormation,并作为其一部分尝试创建S3存储桶。但这由于以下错误而失败:
15:23:25 UTC+0550 CREATE_FAILED AWS::S3::Bucket ServerlessDeploymentBucket API: s3:CreateBucket Access Denied
15:23:24 UTC+0550 CREATE_IN_PROGRESS AWS::S3::Bucket ServerlessDeploymentBucket
Run Code Online (Sandbox Code Playgroud)
我尝试使用aws s3api create-bucket --bucket my-bucket --region us-west-2成功创建存储区的命令创建S3 存储区。我不确定为什么通过无服务器创建S3存储桶时会拒绝访问。这里可能是什么问题?
这是我的serverless.yml档案
service: auth-service-gs
provider:
name: aws
runtime: python2.7
stage: dev2-gs-1
region: us-west-2
profile: mfa
environment:
DB_HOST: "DB_HOST"
DB_USER: "root"
DB_PASS: "<password>"
LOG_LEVEL: "DEBUG"
functions:
login:
handler: handler.login
events:
- http:
path: /api/v1/login
method: post
cors: true
Run Code Online (Sandbox Code Playgroud)
我$serverless deploy
还会使用的内容来部署服务~/.aws/credentials
[mfa]
aws_access_key_id = <ACESS_KEY>
aws_secret_access_key = <SECRET_KEY>
aws_session_token = <SESSION ID>
Run Code Online (Sandbox Code Playgroud)
我通过跑步得到的 …
amazon-s3 amazon-web-services amazon-iam serverless-framework
python ×4
spring-boot ×3
python-2.7 ×2
amazon-iam ×1
amazon-s3 ×1
binding ×1
c# ×1
combobox ×1
docker ×1
dockerfile ×1
hibernate ×1
http ×1
java ×1
jpa ×1
netflix-zuul ×1
post ×1
python-3.x ×1
sockets ×1
spring-mvc ×1
string ×1
unit-testing ×1
urlencode ×1
wpf ×1