我正在阅读这本关于Spring的宁静网络服务的书.我决定放弃他们正在做的事情并使用java配置文件.出于某种原因,在切换到Java配置之后,服务将(在控制台窗口中)正确运行,但是当我实际上在localhost上运行端点时,我得到:
白标错误页面
此应用程序没有/ error的显式映射,因此您将此视为回退.
2016年4月23日星期六20:48:25 PDT 2016出现意外错误(type = Not Found,status = 404).没有可用的消息
这是GET请求的响应:
{
"timestamp": 1461470029110,
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/greeting"
}
Run Code Online (Sandbox Code Playgroud)
这个故事的下一章开始于我访问Spring网站上的入门页面http://spring.io/guides/gs/rest-service/我决定开始一个小项目重新创建他们的基本教程.我将发布下面编写的代码供您查看.问题是,我遇到了完全相同的问题.该服务运行但我无法点击端点.我不确定发生了什么,我看到其他人遇到类似的问题,但答案没有应用/帮助我的.我确信这是明显的,我做错了,任何帮助将不胜感激.最后一条信息,如果完全相关,我使用IntelliJ IDEA 15 CE作为我的IDE.
被点击的端点:
我的控制器
@RestController
public class GreetingController
{
private static final String template = "Hello, %s!";
private final AtomicLong counter = new AtomicLong();
@RequestMapping("/greeting")
public Greeting greeting(@RequestParam(value = "name", defaultValue = "World")String name)
{
return new Greeting(counter.incrementAndGet(), String.format(template, name));
}
}
Run Code Online (Sandbox Code Playgroud)
我的资源表示类
public class Greeting …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用maven插件测试工具来测试我的maven插件.我能在这个问题上找到的唯一文件是相当陈旧的,我发现类似的线程有相同的错误,但没有解决方案,至少没有解决问题的方法.在尝试运行lookupMojo方法时,错误可以归结为抛出NoSuchElementException.
有没有其他人遇到此问题或类似问题,您是如何解决的?如果您需要更多信息,请告诉我,我会发布更新.
插件类
@Mojo(name = "my_plugin", defaultPhase = LifecyclePhase.CLEAN, threadSafe = true)
public class MyPlugin extends AbstractMojo
{
private static final Logger logger = LoggerFactory.getLogger(MyPlugin.class);
@Parameter private String configFileLocation;
public void execute() throws MojoExecutionException, MojoFailureException
{
logger.info("The config file location is: {}", configFileLocation);
saveSystemProperties(new File(configFileLocation));
}
private void saveSystemProperties(final File file)
{
logger.info("Attempting to save system properties");
try(FileOutputStream fr = new FileOutputStream(file))
{
System.getProperties().store(fr, "Properties");
logger.info("Properties successfully saved. Closing File Output Stream …Run Code Online (Sandbox Code Playgroud) 我在 IntelliJ IDEA 中遇到这个奇怪的问题,当我浏览包时,默认情况下 Java 类文件会自动扩展。请参阅以下图片:
这是在我下载最新更新后发生的,我目前正在使用该更新:
IntelliJ IDEA 2016.3.4
Build #IU-163.12024.16, built on January 31, 2017
JRE: 1.8.0_112-release-408-b6 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Run Code Online (Sandbox Code Playgroud)
我认为我没有对配置进行任何更改,但是有时我确实不小心使用了错误的热键,因此我可以使用 cmd + shift + 随机键来打开此功能。