springboot Phoenix开发(踩坑及解决方法)

狄兴业
2023-12-01

常见问题

  • 启动报 guava的错误
  • 找不到驱动
  • idea启动正常,打包启动报错
  • 第三方jar包太大,启动不了
  • 启动正常,但报错 Inconsistent namespace mapping properties. Cannot initiate connection as SYSTEM:CATALOG is found but client does not have phoenix.schema.isNamespaceMappingEnabled enabled

实测解决方法

添加依赖

        <dependency>
            <groupId>org.apache.phoenix</groupId>
            <artifactId>phoenix-4.14.0-cdh5.14.2</artifactId>
            <version>client</version>
        </dependency>

依赖问题

maven下载不到jar就搜索下载jar包,之后使用maven install将jar包install到本地仓库

mvn install:install-file -DlocalRepositoryPath=D:\Home\Java\tools\repository  -Dfile=phoenix-4.14.0-cdh5.14.2-client.jar -DgroupId=org.apache.phoenix -DartifactId=phoenix-4.14.0-cdh5.14.2 -Dversion=client -Dpackaging=jar

成功添加依赖

Idea启动是正常的,打包启动就报错 什么unsupport zip64之类的

解决方法,修改打包方式(Main-Class需要修改成你自己的):

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <dependencies>
                    <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-maven-plugin</artifactId>
                        <version>2.1.6.RELEASE</version>
                    </dependency>
                </dependencies>
                <configuration>
                    <keepDependenciesWithProvidedScope>true</keepDependenciesWithProvidedScope>
                    <createDependencyReducedPom>true</createDependencyReducedPom>
                    <filters>
                        <filter>
                            <artifact>*:*</artifact>
                            <excludes>
                                <exclude>META-INF/*.SF</exclude>
                                <exclude>META-INF/*.DSA</exclude>
                                <exclude>META-INF/*.RSA</exclude>
                            </excludes>
                        </filter>
                    </filters>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                    <resource>META-INF/spring.handlers</resource>
                                </transformer>
                                <transformer
                                        implementation="org.springframework.boot.maven.PropertiesMergingResourceTransformer">
                                    <resource>META-INF/spring.factories</resource>
                                </transformer>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                    <resource>META-INF/spring.schemas</resource>
                                </transformer>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <manifestEntries>
                                        <Main-Class>com.xzkj.kafka.KafkaApplication</Main-Class>
                                    </manifestEntries>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

针对大数据项目,使用jar包多,切依赖包大,可以尝试把依赖包外置,启动运行的时候指定目录,这样也避免每次更新,jar包传输问题

小tips(给我自己用):

  任何maven仓库下载不到的依赖,从网上下载到,然后使用mvn install 到本地仓库,然后就不用使用systemPath来引用了,免得打包的时候,不会被打包进去.

------------------------------------------------------------------------------------------------------------------------------------     一只弱弱的小菜鸡

------------------------------------------------------------------------------------------------------------------------------------2019年12月27日11:54:50

 类似资料: