작은 웹 서버에 spark java를 사용하고 있습니다. 내 메인 클래스에서 나는 설정 물건 내가 필요 Sparkjava 정적 파일 404 restart 후
public static void startServer()
{
if (!starting && !stopping)
{
starting = true;
// Initialize server
port(port);
secure(keystoreLocation, keystorePass, null, null);
// Register all routes
initRoutes();
// Start server
init();
starting = false;
}
}
그리고 initRoutes에서
, 내가 가진 : 그 코드를 실행하면public static void initRoutes()
{
Spark.staticFileLocation("/public");
}
, 나는 로컬 호스트로 이동하여 내용을 볼 수 있어요 내 index.html 페이지의 src/main/resources/public에 있습니다. 내가 서버를 다시 시작하는 프로세스를 실행할 때 staticFileLocation가 손실 될 것으로 보인다
10:24:17.151 [INFO ] - StaticResourceHandler configured with folder = /public
하지만 : 난 로그에이를 참조하십시오.
내 stopServer 메소드 및 restartServer 메소드입니다.
public static void stopServer()
{
if (!stopping && !starting)
{
stopping = true;
stop();
try
{
// This is temporary until the ability to wait for the service to
// stop comes along
Thread.sleep(10 * 1000);
}
catch (InterruptedException ex)
{
LogUtil.warn("Failed to wait while server shuts down", ex);
}
stopping = false;
}
}
public static void restartServer()
{
stopServer();
startServer();
}
로그는이 라인을 보여줍니다
10:33:52.768 [WARN ] - Static file location has already been set
을하지만 다시 홈 페이지에 액세스하려고 할 때, 나는 수 404 및 로그이 말한다 :
10:34:22.260 [INFO ] - The requested route [/] has not been mapped in Spark for Accept: [text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8]
내 다른 경로 (간결함을 위해 생략 됨)를 다시 초기화하십시오. 서버를 다시 시작하고 문제없이 계속 탐색 할 수 있습니다.
정적 파일 위치를 변경할 필요가 없지만 서버를 다시 시작할 때까지이 설정을 유지하고 싶습니다. 내가 다시 시작하는 방법 일 수 있습니까? 그렇게하기위한 적절한 과정에 대한 많은 정보를 찾을 수 없었습니다. 스파크 - 자바 즉, 2.7.0의 새로운 버전으로 고급
왜 그런 식으로 중지하고 시작 하시겠습니까? 또한'Spark' 클래스에서'stop' 메소드를 사용합니까? –
왜 나는 그들을 어떻게 처리할까요? init() 및 stop() 메서드는 Spark 클래스에서 가져온 것입니다. – Troncoso