Spring boot 停靠的spring引导web服务引发FileNotFound异常
我尝试使用Docker File命令将文件从windows计算机复制到Docker容器,并从SpringWeb服务读取这些文件。Webservice抛出一个找不到的错误文件 在这里,我试图将本地目录src/nlp复制到/data container directoty 以下是可用的docker卷 Docker文件 应用程序属性 爪哇 错误Spring boot 停靠的spring引导web服务引发FileNotFound异常,spring-boot,docker,dockerfile,docker-container,file-not-found,Spring Boot,Docker,Dockerfile,Docker Container,File Not Found,我尝试使用Docker File命令将文件从windows计算机复制到Docker容器,并从SpringWeb服务读取这些文件。Webservice抛出一个找不到的错误文件 在这里,我试图将本地目录src/nlp复制到/data container directoty 以下是可用的docker卷 Docker文件 应用程序属性 爪哇 错误 java.io.FileNotFoundException:/data/train/models/en/token/en-token.bin(没有这样的文件
java.io.FileNotFoundException:/data/train/models/en/token/en-token.bin(没有这样的文件或目录)
位于java.io.FileInputStream.open0(本机方法)
在java.io.FileInputStream.open(FileInputStream.java:195)
位于java.io.FileInputStream。(FileInputStream.java:138)
请注意,在列车直达之前,在您的路径上有额外的斜杠
/data//train/models/en/token/en token.bin
考虑将阅读行更改为:
InputStream-InputStream=新文件InputStream(environment.getProperty(“nlp.learning.dir”)+“train/models/en/token/en token.bin”)
最有可能的情况是,您没有一个文件src/nlp/train/models/en/token/en token.bin
用于构建容器的目录
parent/
├── Dockerfile
└── src/
└── nlp/
└── train/
└── models/
└── en/
└── token/
└── en-token.bin <--- does this exist?
parent/
├── Dockerfile
└── src/
└── nlp/
└── 训练/
└── 模型/
└── 嗯/
└── 代币/
└── en-token.bin我已经改变了我的maven插件依赖关系,现在它运行良好
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.7</version>
<!-- Wire up to the default build phases -->
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<repository>${project.artifactId}</repository>
<buildArgs>
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
</configuration>
com.spotify
dockerfile maven插件
1.4.7
违约
建造
推
${project.artifactId}
target/${project.build.finalName}.jar
我现在已经编辑了错误,很抱歉,这是打字错误。。你现在能再查一下吗?它与额外斜杠无关,我相信在添加资源后尝试将运行ls/data/train/models/en/token
或运行cat/data/train/models/en/token/en token.bin
添加到您的Dockerfile中。生成图像时的输出是什么?它应该包含文件名/文件内容
InputStream inputStream = new FileInputStream(environment.getProperty("nlp.learning.dir")+ "/train/models/en/token/en-token.bin");
java.io.FileNotFoundException: /data/train/models/en/token/en-token.bin (No such file or directory)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
parent/
├── Dockerfile
└── src/
└── nlp/
└── train/
└── models/
└── en/
└── token/
└── en-token.bin <--- does this exist?
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.7</version>
<!-- Wire up to the default build phases -->
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
<configuration>
<repository>${project.artifactId}</repository>
<buildArgs>
<JAR_FILE>target/${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
</configuration>