java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed\n; SQL []; Connection is read-only. Queries leading to data modification are not allowed; nested exception is java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed"
原因:package 名不符合规范,如带有数字,则右键菜单中不会出现创建 java class 选项
8、Spring Boot 项目启动报错
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is java.lang.NullPointerException
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:622) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
... 48 common frames omitted
Caused by: java.lang.NullPointerException: null
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_241]
at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[na:1.8.0_241]
at com.alibaba.druid.util.JdbcUtils.createDriver(JdbcUtils.java:589) ~[druid-1.1.10.jar:1.1.10]
at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:817) ~[druid-1.1.10.jar:1.1.10]
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1229) ~[druid-1.1.10.jar:1.1.10]
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:1225) ~[druid-1.1.10.jar:1.1.10]
at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:90) ~[druid-1.1.10.jar:1.1.10]
at io.seata.rm.datasource.DataSourceProxy.init(DataSourceProxy.java:66) ~[seata-all-0.7.1.jar:0.7.1]
at io.seata.rm.datasource.DataSourceProxy.(DataSourceProxy.java:61) ~[seata-all-0.7.1.jar:0.7.1]
at io.seata.rm.datasource.DataSourceProxy.(DataSourceProxy.java:50) ~[seata-all-0.7.1.jar:0.7.1]
at com.changgou.goods.config.DataSourceConfiguration.dataSource(DataSourceConfiguration.java:26) ~[classes/:na]
at com.changgou.goods.config.DataSourceConfiguration$$EnhancerBySpringCGLIB$$38399d80.CGLIB$dataSource$0() ~[classes/:na]
at com.changgou.goods.config.DataSourceConfiguration$$EnhancerBySpringCGLIB$$38399d80$$FastClassBySpringCGLIB$$4d5ff5c1.invoke() ~[classes/:na]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:363) ~[spring-context-5.1.7.RELEASE.jar:5.1.7.RELEASE]
at com.changgou.goods.config.DataSourceConfiguration$$EnhancerBySpringCGLIB$$38399d80.dataSource() ~[classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_241]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_241]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_241]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_241]
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.1.7.RELEASE.jar:5.1.7.RELEASE]
... 49 common frames omitted
Disconnected from the target VM, address: '127.0.0.1:50223', transport: 'socket'
Process finished with exit code 1
原因为配置类的前缀少了druid,修改为
@Bean
@ConfigurationProperties(prefix = "spring.datasource.druid")
public DruidDataSource ds0() {
DruidDataSource druidDataSource = new DruidDataSource();
return druidDataSource;
}
参考 http://www.classinstance.cn/detail/111.html
7、访问微服务报错:java.net.SocketException: Can't connect to SOCKS proxy:Connection refused (Connection refused)
feign.FeignException: status 405 reading AddressFeign#list(String)
at feign.FeignException.errorStatus(FeignException.java:78) ~[feign-core-10.1.0.jar:na]
at feign.codec.ErrorDecoder$Default.decode(ErrorDecoder.java:93) ~[feign-core-10.1.0.jar:na]
at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:149) ~[feign-core-10.1.0.jar:na]
at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:78) ~[feign-core-10.1.0.jar:na]
.......
其中 Feign 接口定义如下:
@GetMapping("/list")
public Result> list(String username);
以上写法为错误写法,以下是正确写法(增加 @RequestParam("username"))
@GetMapping("/list")
public Result> list(@RequestParam("username") String username);
原因:Stack Overflow 上的解释
By default, any parameter to a feign method is treated as the body, so your checkFormat() method will send a post because it has a body (a get cannot).
如报错:java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext 原因是没有把导入的框架放到 WEB-INF 下的 lib 目录。 解决方法:打开 Project Structure,选中 Artifacts,选中项目/模块名,鼠标右键点击右侧 Available Elements 下的模块名,在弹出框中点击 Put into Output Root,这样左侧 WEB-INF 目录下就有了 lib 目录,且包含导入的第三方框架 jar 包。
视图控制层代码demo如下:
@Controller
@RequestMapping("/")
public class MessageController {
private final MessageRepository messageRepository;
@Autowired
public MessageController(Mes
作为一名
Linux SA,日常运维中很多地方都会用到脚本,而服务器的ip一般采用静态ip或者MAC绑定,当然后者比较操作起来相对繁琐,而前者我们可以设置主机名、ip信息、网关等配置。修改成特定的主机名在维护和管理方面也比较方便。如下脚本用途为:修改ip和主机名等相关信息,可以根据实际需求修改,举一反三!
#!/bin/sh
#auto Change ip netmask ga