New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
春松客服 Windows开发时,使用 IDEA,启动后报错 Illegal char <:> at index 9: classpath:/templates/ #408
Comments
提供:部署方式,是在开发环境还是 Chatopera 提供的 docker 容器服务,使用 docker-compose 部署。 |
看错误日志,是在 Windows 上开发?使用了什么 IDE 工具? |
@hailiang-wang |
@mukaiu 是因为
|
开发环境的搭建和项目启动的过程,和开发者文档描述一致吗? https://docs.chatopera.com/products/cskefu/osc/engineering.html 请介绍一下项目启动过程。 |
@hailiang-wang 是一样的, 完全一样的项目, 在Mac上能运行 |
碰到了同样的问题,目前有什么解决方案吗 |
目前只是分析了原因,我们研发同事目前都是 Mac 开发环境,作为开源项目,您可以自己解决,春松客服团队估计在 4 月份可以对 Windows 开发环境完成兼容。 |
This comment has been minimized.
This comment has been minimized.
遇到同样问题 |
感谢建议,该方法测试后还是没有解决问题! |
@viaco2ove 如果需要更新 Pug4j 的插件代码,也是可以的,我们可以发布到 |
按照这个尝试了,还是有问题,有人成功吗 分享加经验 谢谢 public static String getServletPath(String templatePath) throws URISyntaxException { // if (templatePath.substring(0,1).equals("/") ){
引入 pug4j v2.0.0 alpha 3源码,问题解决。我引入的是master SpringTemplateLoader 最新修改方案: PugConfig 改为官方的代码(其实我加多了一个控制变量,跳过Resource 和不跳过Resource) SpringTemplateLoader 中 改为这个
|
就改这一个类么,还需要修改别的文件吗 。您说的这个我之前创建了,不好用 ,根据您发的进行的修改,就是页面一片空白,控制台堆栈也没有报错
在 2021-05-08 17:39:03,"viaco2ove" ***@***.***> 写道:
@xl111
新建下面的类,会自行替代spring-pug4j 的业务实现
package de.neuland.pug4j.spring.template;
import java.io.*;
import java.nio.file.Path;
import java.nio.file.Paths;
import de.neuland.pug4j.template.TemplateLoader;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.ResourceLoaderAware;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.apache.commons.io.FilenameUtils;
public class SpringTemplateLoader implements TemplateLoader, ResourceLoaderAware {
private ResourceLoader resourceLoader;
private String encoding = "UTF-8";
private String suffix = ".pug";
private String templateLoaderPath = "";
private String base = "";
private boolean useSpringResource = true;
public boolean isUseSpringResource() {
return useSpringResource;
}
public void setUseSpringResource(boolean useSpringResource) {
this.useSpringResource = useSpringResource;
}
public long getLastModifiedOld(String name) {
Resource resource = getResource(name);
try {
return resource.lastModified();
} catch (IOException ex) {
return -1;
}
}
/**
* 绕过初一绕不过十五
* @param name
* @return
*/
@OverRide
public long getLastModified(String name) {
Resource resource = getResource(name);
try {
return resource.lastModified();
} catch (IOException ex) {
return -1;
}
}
/**
* 绕过resource
* @param name
* @return
* @throws IOException
*/
@OverRide
public Reader getReader(String name) throws IOException {
//AnnotationConfigEmbeddedWebApplicationContext ServletContextResource
Resource resource = getResource(name);
if(useSpringResource){
return new InputStreamReader(resource.getInputStream(), encoding);
}else {
InputStream in = getInputStream(name);
return new InputStreamReader(in, encoding);
}
}
public InputStream getInputStream(String name) {
String resName = this.getResourceName(name);
//String path = this.getClass().getResource("/").getPath();
//path =path.replace("%20", " ");
InputStream in = this.getClass().getClassLoader().getResourceAsStream(resName);
return in;
}
@OverRide
public String getExtension() {
return suffix.substring(1,suffix.length());
}
private Resource getResource(String name) {
String resourceName = getResourceName(name);
if (hasNoExtension(resourceName)) {
resourceName += suffix;
}
return this.resourceLoader.getResource(resourceName);
}
private String getResourceName(String name){
if(!StringUtils.isBlank(templateLoaderPath)){
if(Paths.get(name).isAbsolute()) {
return Paths.get(templateLoaderPath+ base +name.substring(1)).toString();
}else {
//return Paths.get(templateLoaderPath).resolve(name).toString();
if(useSpringResource){
String nameTemp = name;
if (name.substring(0,1).equals("/") ){
nameTemp = name.substring(1);
}
return (templateLoaderPath + nameTemp);
}else {
Path path = Paths.get(templateLoaderPath,name);
return path.toString();
}
}
}
else {
return name;
}
}
private boolean hasNoExtension(String filename) {
return "".equals(FilenameUtils.getExtension(filename));
}
public String getEncoding() {
return encoding;
}
public void setEncoding(String encoding) {
this.encoding = encoding;
}
public String getSuffix() {
return suffix;
}
public void setSuffix(String suffix) {
this.suffix = suffix;
}
@OverRide
public String getBase() {
return base;
}
public void setBase(String base) {
this.base = base;
}
public void setTemplateLoaderPath(String templateLoaderPath) {
if(templateLoaderPath.endsWith("/")){
this.templateLoaderPath = templateLoaderPath;
}else {
this.templateLoaderPath = templateLoaderPath+"/";
}
}
@OverRide
public void setResourceLoader(ResourceLoader resourceLoader) {
this.resourceLoader = resourceLoader;
}
}
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
只是修改了SpringTemplateLoader类
在 2021-05-08 17:46:51,"viaco2ove" ***@***.***> 写道:
就改这一个类么,还需要修改别的文件吗 。您说的这个我之前创建了,不好用 ,根据您发的进行的修改,就是页面一片空白,控制台堆栈也没有报错 在 2021-05-08 17:39:03,"viaco2ove" @.> 写道: @xl111 新建下面的类,会自行替代spring-pug4j 的业务实现 package de.neuland.pug4j.spring.template; import java.io.; import java.nio.file.Path; import java.nio.file.Paths; import de.neuland.pug4j.template.TemplateLoader; import org.apache.commons.lang3.StringUtils; import org.springframework.context.ResourceLoaderAware; import org.springframework.core.io.Resource; import org.springframework.core.io.ResourceLoader; import org.apache.commons.io.FilenameUtils; public class SpringTemplateLoader implements TemplateLoader, ResourceLoaderAware { private ResourceLoader resourceLoader; private String encoding = "UTF-8"; private String suffix = ".pug"; private String templateLoaderPath = ""; private String base = ""; private boolean useSpringResource = true; public boolean isUseSpringResource() { return useSpringResource; } public void setUseSpringResource(boolean useSpringResource) { this.useSpringResource = useSpringResource; } public long getLastModifiedOld(String name) { Resource resource = getResource(name); try { return resource.lastModified(); } catch (IOException ex) { return -1; } } / * 绕过初一绕不过十五 * @param name * @return/ @OverRide public long getLastModified(String name) { Resource resource = getResource(name); try { return resource.lastModified(); } catch (IOException ex) { return -1; } } /* * 绕过resource * @param name * @return * @throws IOException */ @OverRide public Reader getReader(String name) throws IOException { //AnnotationConfigEmbeddedWebApplicationContext ServletContextResource Resource resource = getResource(name); if(useSpringResource){ return new InputStreamReader(resource.getInputStream(), encoding); }else { InputStream in = getInputStream(name); return new InputStreamReader(in, encoding); } } public InputStream getInputStream(String name) { String resName = this.getResourceName(name); //String path = this.getClass().getResource("/").getPath(); //path =path.replace("%20", " "); InputStream in = this.getClass().getClassLoader().getResourceAsStream(resName); return in; } @OverRide public String getExtension() { return suffix.substring(1,suffix.length()); } private Resource getResource(String name) { String resourceName = getResourceName(name); if (hasNoExtension(resourceName)) { resourceName += suffix; } return this.resourceLoader.getResource(resourceName); } private String getResourceName(String name){ if(!StringUtils.isBlank(templateLoaderPath)){ if(Paths.get(name).isAbsolute()) { return Paths.get(templateLoaderPath+ base +name.substring(1)).toString(); }else { //return Paths.get(templateLoaderPath).resolve(name).toString(); if(useSpringResource){ String nameTemp = name; if (name.substring(0,1).equals("/") ){ nameTemp = name.substring(1); } return (templateLoaderPath + nameTemp); }else { Path path = Paths.get(templateLoaderPath,name); return path.toString(); } } } else { return name; } } private boolean hasNoExtension(String filename) { return "".equals(FilenameUtils.getExtension(filename)); } public String getEncoding() { return encoding; } public void setEncoding(String encoding) { this.encoding = encoding; } public String getSuffix() { return suffix; } public void setSuffix(String suffix) { this.suffix = suffix; } @OverRide public String getBase() { return base; } public void setBase(String base) { this.base = base; } public void setTemplateLoaderPath(String templateLoaderPath) { if(templateLoaderPath.endsWith("/")){ this.templateLoaderPath = templateLoaderPath; }else { this.templateLoaderPath = templateLoaderPath+"/"; } } @OverRide public void setResourceLoader(ResourceLoader resourceLoader) { this.resourceLoader = resourceLoader; } } — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
因为pug4版本太低解析错误了。 引入 pug4j v2.0.0 alpha 3源码,问题解决。我引入的是master
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
简单来说就是 pug4j 的代码地址是这个,自己去下载吧 |
好的 感谢回复。下载后src下的文件都复制到 项目中了,现在可以了 感谢
在 2021-05-08 17:53:15,"viaco2ove" ***@***.***> 写道:
就改这一个类么,还需要修改别的文件吗 。您说的这个我之前创建了,不好用 ,根据您发的进行的修改,就是页面一片空白,控制台堆栈也没有报错 在 2021-05-08 17:39:03,"viaco2ove" @.> 写道: @xl111 新建下面的类,会自行替代spring-pug4j 的业务实现 package de.neuland.pug4j.spring.template; import java.io.; import java.nio.file.Path; import java.nio.file.Paths; import de.neuland.pug4j.template.TemplateLoader; import org.apache.commons.lang3.StringUtils; import org.springframework.context.ResourceLoaderAware; import org.springframework.core.io.Resource; import org.springframework.core.io.ResourceLoader; import org.apache.commons.io.FilenameUtils; public class SpringTemplateLoader implements TemplateLoader, ResourceLoaderAware { private ResourceLoader resourceLoader; private String encoding = "UTF-8"; private String suffix = ".pug"; private String templateLoaderPath = ""; private String base = ""; private boolean useSpringResource = true; public boolean isUseSpringResource() { return useSpringResource; } public void setUseSpringResource(boolean useSpringResource) { this.useSpringResource = useSpringResource; } public long getLastModifiedOld(String name) { Resource resource = getResource(name); try { return resource.lastModified(); } catch (IOException ex) { return -1; } } / * 绕过初一绕不过十五 * @param name * @return/ @OverRide public long getLastModified(String name) { Resource resource = getResource(name); try { return resource.lastModified(); } catch (IOException ex) { return -1; } } /* * 绕过resource * @param name * @return * @throws IOException */ @OverRide public Reader getReader(String name) throws IOException { //AnnotationConfigEmbeddedWebApplicationContext ServletContextResource Resource resource = getResource(name); if(useSpringResource){ return new InputStreamReader(resource.getInputStream(), encoding); }else { InputStream in = getInputStream(name); return new InputStreamReader(in, encoding); } } public InputStream getInputStream(String name) { String resName = this.getResourceName(name); //String path = this.getClass().getResource("/").getPath(); //path =path.replace("%20", " "); InputStream in = this.getClass().getClassLoader().getResourceAsStream(resName); return in; } @OverRide public String getExtension() { return suffix.substring(1,suffix.length()); } private Resource getResource(String name) { String resourceName = getResourceName(name); if (hasNoExtension(resourceName)) { resourceName += suffix; } return this.resourceLoader.getResource(resourceName); } private String getResourceName(String name){ if(!StringUtils.isBlank(templateLoaderPath)){ if(Paths.get(name).isAbsolute()) { return Paths.get(templateLoaderPath+ base +name.substring(1)).toString(); }else { //return Paths.get(templateLoaderPath).resolve(name).toString(); if(useSpringResource){ String nameTemp = name; if (name.substring(0,1).equals("/") ){ nameTemp = name.substring(1); } return (templateLoaderPath + nameTemp); }else { Path path = Paths.get(templateLoaderPath,name); return path.toString(); } } } else { return name; } } private boolean hasNoExtension(String filename) { return "".equals(FilenameUtils.getExtension(filename)); } public String getEncoding() { return encoding; } public void setEncoding(String encoding) { this.encoding = encoding; } public String getSuffix() { return suffix; } public void setSuffix(String suffix) { this.suffix = suffix; } @OverRide public String getBase() { return base; } public void setBase(String base) { this.base = base; } public void setTemplateLoaderPath(String templateLoaderPath) { if(templateLoaderPath.endsWith("/")){ this.templateLoaderPath = templateLoaderPath; }else { this.templateLoaderPath = templateLoaderPath+"/"; } } @OverRide public void setResourceLoader(ResourceLoader resourceLoader) { this.resourceLoader = resourceLoader; } } — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
pug4j
就改这一个类么,还需要修改别的文件吗 。您说的这个我之前创建了,不好用 ,根据您发的进行的修改,就是页面一片空白,控制台堆栈也没有报错 在 2021-05-08 17:39:03,"viaco2ove" @.> 写道: @xl111 新建下面的类,会自行替代spring-pug4j 的业务实现 package de.neuland.pug4j.spring.template; import java.io.; import java.nio.file.Path; import java.nio.file.Paths; import de.neuland.pug4j.template.TemplateLoader; import org.apache.commons.lang3.StringUtils; import org.springframework.context.ResourceLoaderAware; import org.springframework.core.io.Resource; import org.springframework.core.io.ResourceLoader; import org.apache.commons.io.FilenameUtils; public class SpringTemplateLoader implements TemplateLoader, ResourceLoaderAware { private ResourceLoader resourceLoader; private String encoding = "UTF-8"; private String suffix = ".pug"; private String templateLoaderPath = ""; private String base = ""; private boolean useSpringResource = true; public boolean isUseSpringResource() { return useSpringResource; } public void setUseSpringResource(boolean useSpringResource) { this.useSpringResource = useSpringResource; } public long getLastModifiedOld(String name) { Resource resource = getResource(name); try { return resource.lastModified(); } catch (IOException ex) { return -1; } } / * 绕过初一绕不过十五 * @param name * @return/ @OverRide public long getLastModified(String name) { Resource resource = getResource(name); try { return resource.lastModified(); } catch (IOException ex) { return -1; } } /* * 绕过resource * @param name * @return * @throws IOException */ @OverRide public Reader getReader(String name) throws IOException { //AnnotationConfigEmbeddedWebApplicationContext ServletContextResource Resource resource = getResource(name); if(useSpringResource){ return new InputStreamReader(resource.getInputStream(), encoding); }else { InputStream in = getInputStream(name); return new InputStreamReader(in, encoding); } } public InputStream getInputStream(String name) { String resName = this.getResourceName(name); //String path = this.getClass().getResource("/").getPath(); //path =path.replace("%20", " "); InputStream in = this.getClass().getClassLoader().getResourceAsStream(resName); return in; } @OverRide public String getExtension() { return suffix.substring(1,suffix.length()); } private Resource getResource(String name) { String resourceName = getResourceName(name); if (hasNoExtension(resourceName)) { resourceName += suffix; } return this.resourceLoader.getResource(resourceName); } private String getResourceName(String name){ if(!StringUtils.isBlank(templateLoaderPath)){ if(Paths.get(name).isAbsolute()) { return Paths.get(templateLoaderPath+ base +name.substring(1)).toString(); }else { //return Paths.get(templateLoaderPath).resolve(name).toString(); if(useSpringResource){ String nameTemp = name; if (name.substring(0,1).equals("/") ){ nameTemp = name.substring(1); } return (templateLoaderPath + nameTemp); }else { Path path = Paths.get(templateLoaderPath,name); return path.toString(); } } } else { return name; } } private boolean hasNoExtension(String filename) { return "".equals(FilenameUtils.getExtension(filename)); } public String getEncoding() { return encoding; } public void setEncoding(String encoding) { this.encoding = encoding; } public String getSuffix() { return suffix; } public void setSuffix(String suffix) { this.suffix = suffix; } @OverRide public String getBase() { return base; } public void setBase(String base) { this.base = base; } public void setTemplateLoaderPath(String templateLoaderPath) { if(templateLoaderPath.endsWith("/")){ this.templateLoaderPath = templateLoaderPath; }else { this.templateLoaderPath = templateLoaderPath+"/"; } } @OverRide public void setResourceLoader(ResourceLoader resourceLoader) { this.resourceLoader = resourceLoader; } } — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
简单来说就是
pug4j 和 spring-pug4j 都是有问题的
pug4j 的代码地址是这个,自己去下载吧
https://github.com/neuland/pug4j
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
最新的代码已经升级 spring-pug4j 和 pug4j 版本,请拉取后,使用
然后,在 IDEA 中进行验证。 |
@all-contributors please add @xl111 for code |
I've put up a pull request to add @xl111! 🎉 |
@all-contributors please add @viaco2ove for code |
I've put up a pull request to add @viaco2ove! 🎉 |
@all-contributors please add @understanding for test |
I've put up a pull request to add @understanding! 🎉 |
@all-contributors please add @MQPearth for test |
I've put up a pull request to add @MQPearth! 🎉 |
@all-contributors please add @SkorpiosL for test |
I've put up a pull request to add @SkorpiosL! 🎉 |
你拉错分支啦,我拉得master 就没有问题,拉7.0标签的就有这个问题 |
很久之前的事情了
…------------------ 原始邮件 ------------------
发件人: ***@***.***>;
发送时间: 2022年11月30日(星期三) 中午11:45
收件人: ***@***.***>;
抄送: ***@***.***>; ***@***.***>;
主题: Re: [cskefu/cskefu] 春松客服 Windows开发时,使用 IDEA,启动后报错 Illegal char <:> at index 9: classpath:/templates/ (#408)
你拉错分支啦,我拉得master 就没有问题,拉7.0标签的就有这个问题
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
描述
java.nio.file.InvalidPathException: Illegal char <:> at index 9: classpath:/templates/
http://localhost:8035/login.html 访问页面后报错
完整堆栈
The text was updated successfully, but these errors were encountered: