1. 导入对应的jar包

		<dependency>
            <groupId>com.belerweb</groupId>
            <artifactId>pinyin4j</artifactId>
            <version>2.5.1</version>
        </dependency>

2. 编写ChineseToPinyinUtils工具类

package com.zhangsan.utils;

import com.google.common.collect.Lists;
import net.sourceforge.pinyin4j.PinyinHelper;
import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType;
import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat;
import net.sourceforge.pinyin4j.format.HanyuPinyinToneType;
import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination;

import java.util.List;

/**
 * 汉字转换为拼音
 *
 * @author Red
 */
public class ChineseToPinyinUtils{

    public static void main(String[] args) {
        List<String> str = Lists.newArrayList();
        str.add("贾丝萌");
        str.add("张继伟");
        str.add("郭恩泽");
        str.add("史睿");
        str.add("张洁");
        str.add("李芙摇");
        str.add("王琪彪");
        ToPinyin(str).forEach(System.out::println);
    }

    /**
     * TODO 获取字符串的第一个字母
     *
     * @param chinese
     * @return java.lang.String
     * @Author ZhangSan_Plus
     * @Description
     * @Date 11:13 2021/11/13
     **/
    public static String ToFirstChar(String chinese) {
        String pinyinStr = "";
        char[] newChar = chinese.toCharArray();
        HanyuPinyinOutputFormat defaultFormat = getPinyinOutPut();
        for (int i = 0; i < newChar.length; i++) {
            if (newChar[i] > 128) {
                try {
                    pinyinStr += PinyinHelper.toHanyuPinyinStringArray(newChar[i], defaultFormat)[0].charAt(0);
                } catch (BadHanyuPinyinOutputFormatCombination e) {
                    e.printStackTrace();
                }
            } else {
                pinyinStr += newChar[i];
            }
        }
        return pinyinStr;
    }

    /**
     * TODO 获取HanyuPinyinOutputFormat 初始化对象
     *
     * @param
     * @return net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat
     * @Author ZhangSan_Plus
     * @Description
     * @Date 11:16 2021/11/13
     **/
    private static HanyuPinyinOutputFormat getPinyinOutPut() {
        HanyuPinyinOutputFormat defaultFormat = new HanyuPinyinOutputFormat();
        defaultFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE);
        defaultFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE);
        return defaultFormat;
    }

    /**
     * TODO 将汉字转为拼音
     *
     * @param chinese 中文集合(可根据执行需要进行灵活变动)
     * @return java.util.List<java.lang.String>
     * @Author ZhangSan_Plus
     * @Description
     * @Date 11:16 2021/11/13
     **/
    public static List<String> ToPinyin(List<String> chinese) {
        List<String> pinyin = Lists.newArrayList();
        chinese.forEach(c -> {
            String pinyinStr = "";
            char[] newChar = c.toCharArray();
            HanyuPinyinOutputFormat defaultFormat = getPinyinOutPut();
            for (int i = 0; i < newChar.length; i++) {
                if (newChar[i] > 128) {
                    try {
                        pinyinStr += PinyinHelper.toHanyuPinyinStringArray(newChar[i], defaultFormat)[0];
                    } catch (BadHanyuPinyinOutputFormatCombination e) {
                        e.printStackTrace();
                    }
                } else {
                    pinyinStr += newChar[i];
                }
            }
            pinyin.add(pinyinStr);
        });
        return pinyin;
    }
}

Q.E.D.