请问,在eclipse spring如何添加配置文件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了请问,在eclipse spring如何添加配置文件相关的知识,希望对你有一定的参考价值。

配置完用户库后,怎么找到写配置文件的地方?我怎么找不到?我刚开始学J2EE,还希望各位不吝赐教
还有,那个log4j.properties文件在哪写?

参考技术A log4j.properties,放在项目的scr目录下
log4j.properties是要自己写的(新建一个log4j.properties文件),网上有很多参考模板.
配置文件是xml格式的,在程序里面调用就可以了(注意路径)本回答被提问者采纳
参考技术B 可以在help->eclipse
marketplace安装插件1
,spring
tool
suit
(sts)
2,
hibernate
tools
将这两个插件安装好,再输入class名就会有提示。

如何在 Eclipse 和 Window 10 上配置 AWS SAM

【中文标题】如何在 Eclipse 和 Window 10 上配置 AWS SAM【英文标题】:How to configure AWS SAM on Eclipse and Window 10 【发布时间】:2019-05-23 19:41:31 【问题描述】:

我正在使用 STS 4 (https://spring.io/tools) 并添加了 Eclipse AWS 工具包 (https://marketplace.eclipse.org/content/aws-toolkit-eclipse)。

重启 STS 后,我们可以看到一切正常。

现在我已经在本地安装了 AWS SAM CLI

并配置了我们拥有 sam.exe 的路径

我在本地安装了 Java 8 和 Python 2.7 和 3.6 以及 docker。

现在创建了 AWS Java serverless 项目 maven install 并尝试运行 sam local

https://aws.amazon.com/blogs/developer/aws-toolkit-for-eclipse-locally-debug-your-lambda-functions-and-api-gateway/

更新:

当我尝试运行 SAM-CLI 时,它的工作和返回响应。

Template.yaml

AWSTemplateFormatVersion : '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: AWS Lambda Sample Project

Resources:

  Products:
    Type: AWS::Serverless::Function
    Properties:
      Handler: com.example.handler.LambdaHandler
      CodeUri: ./target/lambda-project-1.0-SNAPSHOT.jar
      Runtime: java8
      Timeout: 300
      Environment:
        Variables:
          ENVIRONMENT: "test"
      Events:
        ListProducts:
          Type: Api
          Properties:
            Path: /lambda
            Method: post

并运行配置

**Maven build :**


[INFO] Scanning for projects...
[INFO] 
[INFO] ---------------------< com.example:lambda-project >---------------------
[INFO] Building lambda-project 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ lambda-project ---
[INFO] Deleting C:\Users\vaqua\Documents\code\AWS-Lambda-Example-master\AWS-Lambda-Example-master\target
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ lambda-project ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.6.1:compile (default-compile) @ lambda-project ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 6 source files to C:\Users\vaqua\Documents\code\AWS-Lambda-Example-master\AWS-Lambda-Example-master\target\classes
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ lambda-project ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.6.1:testCompile (default-testCompile) @ lambda-project ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
[INFO] Compiling 1 source file to C:\Users\vaqua\Documents\code\AWS-Lambda-Example-master\AWS-Lambda-Example-master\target\test-classes
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ lambda-project ---
[INFO] Surefire report directory: C:\Users\vaqua\Documents\code\AWS-Lambda-Example-master\AWS-Lambda-Example-master\target\surefire-reports

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running com.example.handler.LambdaHandlerTest
Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.291 sec

Results :

Tests run: 2, Failures: 0, Errors: 0, Skipped: 0

[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ lambda-project ---
[INFO] Building jar: C:\Users\vaqua\Documents\code\AWS-Lambda-Example-master\AWS-Lambda-Example-master\target\lambda-project-1.0-SNAPSHOT.jar
[INFO] 
[INFO] --- maven-shade-plugin:3.1.0:shade (default) @ lambda-project ---
[INFO] Including com.amazonaws:aws-lambda-java-events:jar:2.0.2 in the shaded jar.
[INFO] Including joda-time:joda-time:jar:2.6 in the shaded jar.
[INFO] Including com.amazonaws:aws-lambda-java-core:jar:1.2.0 in the shaded jar.
[INFO] Including com.typesafe:config:jar:1.3.1 in the shaded jar.
[INFO] Including org.apache.logging.log4j:log4j-api:jar:2.5 in the shaded jar.
[INFO] Including org.apache.logging.log4j:log4j-core:jar:2.5 in the shaded jar.
[INFO] Including com.google.code.gson:gson:jar:2.8.2 in the shaded jar.
[INFO] Replacing original artifact with shaded artifact.
[INFO] Replacing C:\Users\vaqua\Documents\code\AWS-Lambda-Example-master\AWS-Lambda-Example-master\target\lambda-project-1.0-SNAPSHOT.jar with C:\Users\vaqua\Documents\code\AWS-Lambda-Example-master\AWS-Lambda-Example-master\target\lambda-project-1.0-SNAPSHOT-shaded.jar
[INFO] Dependency-reduced POM written at: C:\Users\vaqua\Documents\code\AWS-Lambda-Example-master\AWS-Lambda-Example-master\dependency-reduced-pom.xml
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.510 s
[INFO] Finished at: 2018-12-25T21:27:10-06:00
[INFO] ------------------------------------------------------------------------

错误日志:

无法启动 SAM Local。 com.amazonaws.eclipse.core.exceptions.AwsActionException

日志:

eclipse.buildId=4.0.2.201811300843-RELEASE
java.version=1.8.0_191
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments:  -product org.springframework.boot.ide.branding.sts4
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.springframework.boot.ide.branding.sts4

com.amazonaws.eclipse.lambda
Error
Tue Dec 25 21:21:52 CST 2018
Failed to launch SAM Local.

com.amazonaws.eclipse.core.exceptions.AwsActionException
    at com.amazonaws.eclipse.lambda.launching.SamLocalDelegate.launch(SamLocalDelegate.java:159)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:862)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:720)
    at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1029)
    at org.eclipse.debug.internal.ui.DebugUIPlugin$2.run(DebugUIPlugin.java:1243)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: java.lang.NullPointerException
    at com.amazonaws.eclipse.lambda.launching.SamLocalDelegate.launch(SamLocalDelegate.java:116)
    ... 5 more

eclipse.buildId=4.0.2.201811300843-RELEASE
java.version=1.8.0_191
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments:  -product org.springframework.boot.ide.branding.sts4
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.springframework.boot.ide.branding.sts4

org.eclipse.m2e.logback.appender
Warning
Tue Dec 25 21:21:47 CST 2018
Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!

我想知道是否有人解决了这个问题?

【问题讨论】:

你能解决这个问题吗?我得到完全相同的错误 【参考方案1】:

遇到同样的问题,进行了以下更改并能够继续...

在图片中的“并运行配置”部分中。 确保您已展开“高级”部分并添加了所需的信息,

AWS 配置

SAM 本地配置(应该设置)。

还可以尝试添加执行以下操作。 在您的文件夹中 C:\Users\YOUR_USER.aws 您应该看到两个文件、凭据和配置。 我没有文件配置,所以我创建了它并添加了以下内容:

[default]
region=YOUR_REGION

我还在凭据文件的 [用户名] 下添加了以下行:

region=YOUR_REGION

我保存并重新启动所有内容并使其正常工作。 现在我还有一些其他问题。但它们特定于 JSON 解析。

【讨论】:

【参考方案2】:

有同样的问题。

首先你应该打开命令行并运行 where sam 如果您发现路径包含任何空格,例如,如果路径中有“程序文件”,则卸载 samcli 并重新安装。确保其路径不包含任何空格,例如:C:\Amazon\SAMCLI。当你完成安装 samcli 后,在 cmd 中重新运行之前的代码,并复制路径并粘贴到 eclipse 中。

其次,您应该按照 Dimman 的建议创建配置文件。您可以通过运行使用 awscli 来执行此操作 aws configuration

这将自动创建文件。保存并重新启动,一切都应该没问题。

祝你好运。

【讨论】:

您也可以将“c:\Program Files\...”部分替换为“C:\Progra~1\...”部分而不必重新安装SAM?我在我的 windows/eclipse 工作站上尝试过,它似乎没有帮助,但它可能对某些人有用? 我从 dos 做了“where sam”,它是 sam.cmd 版本(不是 sam.exe)版本?这些似乎都不起作用?有关如何解决此问题的任何进一步建议?

以上是关于请问,在eclipse spring如何添加配置文件的主要内容,如果未能解决你的问题,请参考以下文章

请问eclipse搭建SSM(spring+springmvc+mybatis)一定要用maven来搭建吗

请问eclipse中如何让自动添加的括号中间添加上空格

Eclipse下如何配置spring应用

请问如何在eclipse中运行.html的文件?

eclipse3.5如何配置spring web开发环境

请问如何在eclipse里面修改jboss的应用发布路径?默认通过localhost:8080加上