每个周末我都在编写一个个人项目,随着时间的推移已经达到了一定程度的复杂性,在那里我有不同功能的序列来接受我的输入,我保存在一些类对象中,将其删除,处理它然后最后输出它.
由于我在编码会话之间做了很大的休息,我通常会忘记代码的精确结构.因此,每次我遇到错误时,我都必须重新熟悉输入数据如何在我的代码中流动,如何在一些提供功能的模块内部组织等等.
我不确定这是由于我的软件的代码结构不好,还是仅仅是固有的复杂性.
是否有一个工具,在给定源代码的情况下,直观地向我展示了我的代码的"架构",即类方法和函数如何一起工作?
理想情况下,这也可以帮助我理解其他人写得更快的代码,快速了解各个代码片段之间的交互方式.
(我用Pycharm在Python中编码,如果这对你有帮助的话.)
python architecture production-environment pycharm productivity-power-tools
在Spring Boot中,该文档似乎鼓励在应用程序启动时运行迁移。
很好,但是有时候应用启动可能会带来副作用/依赖关系,我不想打扰-我只想自己运行迁移。可以考虑只建立一个本地开发数据库,在其中运行甚至无需运行该应用程序。
相比之下,在Dropwizard中,只需使用应用程序的内置参数即可直接运行迁移,就像这样
java -jar hello-world.jar db migrate helloworld.yml
Run Code Online (Sandbox Code Playgroud)
Spring Boot有什么等效的东西吗?还是只需要直接下拉并运行liquibase?
我对直接答案很感兴趣,但也有兴趣看看我是否对更高层次的东西有误解-例如,由于某些我尚未发现的原因,这种在启动时运行的方法通常会“更好”,因此,Spring Boot鼓励您仅以此方式作为设计选择。
朋友们,
我正在分析一些文本.我的要求是对用不同母语的英文字母书写的地址进行地理编码.
Ex: chandpur market ke paas, village gorthaniya, UP, INDIA
Run Code Online (Sandbox Code Playgroud)
在上面的句子中,"ke paas" - >是一个HINDI词(印度民族语言),在英语中意为"近",而"chandapur market"是一个名词(可以忽略转换)
现在我的挑战是将成千上万的单词转换为英语并识别街道名称和地理代码.不幸的是,我没有邮政编码或确切的地址.
你能帮忙吗?
提前致谢 !!
我正在尝试在我的 Spring 启动应用程序上配置 CORS。我将 CrossOrigin 注释添加到我的控制器类中。
@CrossOrigin
@RestController
@RequestMapping("api/user")
public class UserApiController {
...
}
Run Code Online (Sandbox Code Playgroud)
当我在我的本地机器上运行它时,我得到了这些 OPTIONS 请求的响应头:
Access-Control-Allow-Credentials ?true
Access-Control-Allow-Methods ?GET
Access-Control-Allow-Origin ?http://www.test.be
Access-Control-Max-Age ?1800
Allow ?GET, HEAD, POST, PUT, DELETE, TRACE, OPTIONS, PATCH
Cache-Control ?no-cache, no-store, max-age=0, must-revalidate
Content-Length ?0
Date ?Wed, 28 Mar 2018 09:13:33 GMT
Expires ?0
Pragma ?no-cache
Vary ?Origin
X-Content-Type-Options ?nosniff
X-Frame-Options ?DENY
X-XSS-Protection ?1; mode=block
Run Code Online (Sandbox Code Playgroud)
我在 Tomcat 服务器上部署了这个应用程序,在 Linux 上运行的 Apache2 服务器后面。当我在那里做同样的请求时,我得到了这个:
Allow ?GET,HEAD
Cache-Control ?no-cache, no-store, max-age=0, must-revalidate
Connection ?Keep-Alive
Date ?Wed, …Run Code Online (Sandbox Code Playgroud) 我正在编写集成测试,它应该只适用于特定的配置文件。问题是我应该从 application.properties 文件中的 spring.profiles.active 值中获取配置文件名称。但由于 application.properties 的实际价值,我总是得到 null。
我为 main 方法创建了明确地将值放入 System.properties 的方法:
@SpringBootApplication
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
@Autowired
public MyApplication(Environment environment) {
String property = "spring.profiles.active";
System.getProperties().setProperty(property, environment.getProperty(property));
}
Run Code Online (Sandbox Code Playgroud)
但该值仍然为空。在测试类中,我使用以下注释:
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = MyApplication.class)
@SpringBootTest(classes=MyApplication.class)
Run Code Online (Sandbox Code Playgroud)
对于从主类加载上下文,我手动设置了必要的值。也尝试使用@TestPropertySource("classpath:application.properties")
但没有任何帮助。而且我无法对该值进行硬编码。它应该只能从 application.properties 获取
更新 这是我的错误。我已经从静态方法中尝试过 getValue :/ 也许有人知道如何通过使用这个值来禁用类测试?@IfProfileValue 仍然返回 null,因此不适合。
更新 我意识到禁用是无用的,最好使用@SpringBootTest(classes=AppropriateConfigClass.class) 使用适当的配置
我会选择gargkshitiz作为已解决的答案,因为他是唯一一个试图提供帮助的人。
我们有 Airflow 运行(使用 Docker compose),并且有多个 DAG 处于活动状态。上周我们将 Airflow 更新至版本 2.1.3。这导致我们使用 DockerOperator 的 DAG 出现错误:
airflow.exceptions.AirflowException: Invalid arguments were passed to DockerOperator (task_id: t_docker). Invalid arguments were:
**kwargs: {'volumes':
Run Code Online (Sandbox Code Playgroud)
我发现这个发行说明告诉我
airflow.providers.docker.operators.docker.DockerOperator和airflow.providers.docker.operators.docker_swarm.DockerSwarmOperator中的volumes参数被mounts参数替换
所以我将 DAG 更改为
t_docker = DockerOperator(
task_id='t_docker',
image='customimage:latest',
container_name='custom_1',
api_version='auto',
auto_remove=True,
volumes=['/home/airflow/scripts:/opt/airflow/scripts','/home/airflow/data:/opt/airflow/data'],
docker_url='unix://var/run/docker.sock',
network_mode='bridge',
dag=dag
)
Run Code Online (Sandbox Code Playgroud)
对此
t_docker = DockerOperator(
task_id='t_docker',
image='customimage:latest',
container_name='custom_1',
api_version='auto',
auto_remove=True,
mounts=['/home/airflow/scripts:/opt/airflow/scripts','/home/airflow/data:/opt/airflow/data'],
docker_url='unix://var/run/docker.sock',
network_mode='bridge',
dag=dag
)
Run Code Online (Sandbox Code Playgroud)
但现在我得到这个错误:
docker.errors.APIError: 500 Server Error for http+docker://localhost/v1.41/containers/create?name=custom_1: Internal Server Error ("json: cannot unmarshal string into Go struct field …Run Code Online (Sandbox Code Playgroud) java ×3
spring-boot ×3
python ×2
airflow ×1
apache2 ×1
architecture ×1
cors ×1
docker ×1
geocoding ×1
google-maps ×1
junit ×1
liquibase ×1
pycharm ×1
r ×1
tomcat9 ×1