Closed jiash closed 5 years ago
@nobodyiam 您好:根据您说的,我用spring.config.location指定配置文件,但还是没能成功,请再详细的指点下吧。 我猜想,config,admin应该是只需要一个配置文件,但是启动失败了,报错和下面portal的一样,我用的命令是: ··· --spring.config.location=file:/opt/config/apollo-configservice/application-github.properties ··· portal工程应该至少要指定两个配置文件,假设apollo-portal的配置文件放在/opt/config/apollo-portal下面
[root@tomcat10 ~]# ll /opt/config/apollo-portal/*.properties
-rw-r--r-- 1 root root 217 Apr 30 09:43 /opt/config/apollo-portal/apollo-env.properties
-rw-r--r-- 1 root root 178 Apr 30 09:43 /opt/config/apollo-portal/application-github.properties
-rw-r--r-- 1 root root 30 Apr 30 09:43 /opt/config/apollo-portal/app.properties
我在启动脚本中指定三个配置文件的地址,如下,报错信息和config基本是一样的
-----启动命令-----
java -jar /opt/apollo-portal/apollo-portal.jar --spring.config.location=file:/opt/config/apollo-portal/apollo-env.properties,file:/opt/config/apollo-portal/application-github.properties,file:/opt/config/apollo-portal/app.properties
-----报错信息-----
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'openApiAuthenticationFilter' defined in class path resource [com/ctrip/framework/apollo/portal/spi/configuration/AuthFilterConfiguration.class]: Unsatisfied dependency expressed through method 'openApiAuthenticationFilter' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'consumerAuthUtil' defined in URL [jar:file:/opt/apollo-portal/apollo-portal.jar!/com/ctrip/framework/apollo/openapi/util/ConsumerAuthUtil.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'consumerService' defined in URL [jar:file:/opt/apollo-portal/apollo-portal.jar!/com/ctrip/framework/apollo/openapi/service/ConsumerService.class]: Unsatisfied dependency expressed through constructor parameter 5; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'portalConfig': Invocation of init method failed; nested exception is org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:732)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:474)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1247)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1096)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:535)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:495)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:204)
at org.springframework.boot.web.servlet.ServletContextInitializerBeans.getOrderedBeansOfType(ServletContextInitializerBeans.java:226)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'apolloportaldb.server_config' doesn't exist
apollo中有不少配置文件是在代码的classpath中的,这些除非你全部拷出来并通过spring.config.location指定,不然还是建议spring.config.location保留原来的配置,然后增加你需要的外部文件夹或文件地址。
Config locations are searched in reverse order. By default, the configured locations are classpath:/,classpath:/config/,file:./,file:./config/
好的,我再研究下,非常感谢。
您好:目前三个工程配置分离,配置文件是放在config文件夹下了,但是如果想把配置文件放在其他的地方,应该怎么修改启动脚本呢?