The compound as shown in formula I: wherein X is selected from CR 1 or N; R 1 is selected from hydrogen, halogen, C 1-10 alkyl, C 2-10 alkenyl, C 2-10 alkynyl, 3-10 membered cycloalkyl, 3-10 membered heterocycloalkyl, -CN, -NO 2, -OR a, -OC R a, -OC NR a R b, - OS 2 R a, -SR a, -S 2 R a, -S 2 NR a R b, -OS 2 NR a R b, -C R a, -C OR a, -C NR a R b, - NR a R b, -NR a C R b, -NR a C OR b, -NR a C NR a R b, -NR a S 2 R b, and -NR a S 2 NR a R b; wherein the alkyl, alkenyl, alkynyl, cycloalkyl, and heterocycloalkyl are substituted with m R c; R 2 is selected from hydrogen, C 1-10 alkyl, 3-10 membered cycloalkyl, 3-10 membered heterocycloalkyl, -S 2 R a, -S 2 NR a R b, -C R a,- C OR a, and -C NR a R b; wherein the alkyl, cycloalkyl, and heterocycloalkyl are substituted with m R c; R 3 is selected from hydrogen, halogen, C 1-10 alkyl, C 2-10 alkenyl, C 2-10 alkynyl, 3-10 membered cycloalkyl, 3-10 membered heterocycloalkyl, -CN, -NO 2, -ORa, -C R a, -C OR a, -C NR a R b, -NR a R b, and -NR a C R b; wherein the alkyl, alkenyl, alkynyl, cycloalkyl, and heterocycloalkyl are substituted with m R c; or R 2 and R 3 are connected to form a 4-10-membered heterocycle; wherein the formed heterocycle is substituted with m R c; R 4 is selected from hydrogen, C 1-10 alkyl, 3-10 membered cycloalkyl, 3-10 membered heterocycloalkyl, -S 2 R a, -S 2 NR a R b, -C R a, -C OR a, and -C NR a R b; wherein the alkyl, cycloalkyl, and heterocycloalkyl are substituted with m R c; ring A is selected from a benzene ring, a naphthalene ring and a 5-10 membered aromatic heterocycle; n is 1, 2, 3, or 4; Rs is independently selected from hydrogen, halogen, C 1-10 alkyl, C 2-10 alkenyl, C 2-10 alkynyl, 3-10 membered cycloalkyl, 3-10 membered heterocycloalkyl, -CN, -NO 2, -OR a, -OC R a, - OC NR a R b, -OS 2 R a, -SR a, -S 2 R a, -S 2 NR a R b, -OS 2 NR a R b, -C R a, -C OR a, - C NR a R b, -NR a R b, -NR a C R b, -NR a C OR b, -NR a C NR a R b, -NR a S 2 R b, and - NR a S 2 NR a R b; wherein the alkyl, alkenyl, alkynyl, cycloalkyl, and heterocycloalkyl are substituted with m R c; Y is selected from O, S, -NR a, and -C(R a R b)-; L is selected from C 1-10 alkylene, C 2-10 alkenylene, and C 2-10 alkynylene; wherein the alkylene, alkenylene, and alkynylene are substituted with m R c; m is independently 0, 1, 2, 3, or 4; R a and R b are independently selected from hydrogen, C 1-10 alkyl, C 2-10 alkenyl, C 2-10 alkynyl, 3-10 membered cycloalkyl, and 3-10 membered heterocycloalkyl; and R c is independently selected from C 1-10 alkyl, halogen, -CN, -NO 2, -OR a, -OC R a, - OS 2 R a, -SR a, -S 2 R a, -S 2 NR a R b, -C R a, -C OR a, -C NR a R b, -NR a R b, -NR a C R b, and -NR a S 2 R b, or a stereoisomer thereof, or a pharmaceutically acceptable salt thereof. X is selected from CR 1 or N; R 1 is selected from hydrogen, halogen, C 1-10 alkyl, C 2-10 alkenyl, C 2-10 alkynyl, 3-10 membered cycloalkyl, 3-10 membered heterocycloalkyl, -CN, -NO 2, -OR a, -OC R a, -OC NR a R b, - OS 2 R a, -SR a, -S 2 R a, -S 2 NR a R b, -OS 2 NR a R b, -C R a, -C OR a, -C NR a R b, - NR a R b, -NR a C R b, -NR a C OR b, -NR a C NR a R b, -NR a S 2 R b, and -NR a S 2 NR a R b; wherein the alkyl, alkenyl, alkynyl, cycloalkyl, and heterocycloalkyl are substituted with m R c; R 2 is selected from hydrogen, C 1-10 alkyl, 3-10 membered cycloalkyl, 3-10 membered heterocycloalkyl, -S 2 R a, -S 2 NR a R b, -C R a,- C OR a, and -C NR a R b; wherein the alkyl, cycloalkyl, and heterocycloalkyl are substituted with m R c; R 3 is selected from hydrogen, halogen, C 1-10 alkyl, C 2-10 alkenyl, C 2-10 alkynyl, 3-10 membered cycloalkyl, 3-10 membered heterocycloalkyl, -CN, -NO 2, -ORa, -C R a, -C OR a, -C NR a R b, -NR a R b, and -NR a C R b; wherein the alkyl, alkenyl, alkynyl, cycloalkyl, and heterocycloalkyl are substituted with m R c; or R 2 and R 3 are connected to form a 4-10-membered heterocycle; wherein the formed heterocycle is substituted with m R c; R 4 is selected from hydrogen, C 1-10 alkyl, 3-10 membered cycloalkyl, 3-10 membered heterocycloalkyl, -S 2 R a, -S 2 NR a R b, -C R a, -C OR a, and -C NR a R b; wherein the alkyl, cycloalkyl, and heterocycloalkyl are substituted with m R c; ring A is selected from a benzene ring, a naphthalene ring and a 5-10 membered aromatic heterocycle; n is 1, 2, 3, or 4; Rs is independently selected from hydrogen, halogen, C 1-10 alkyl, C 2-10 alkenyl, C 2-10 alkynyl, 3-10 membered cycloalkyl, 3-10 membered heterocycloalkyl, -CN, -NO 2, -OR a, -OC R a, - OC NR a R b, -OS 2 R a, -SR a, -S 2 R a, -S 2 NR a R b, -OS 2 NR a R b, -C R a, -C OR a, - C NR a R b, -NR a R b, -NR a C R b, -NR a C OR b, -NR a C NR a R b, -NR a S 2 R b, and - NR a S 2 NR a R b; wherein the alkyl, alkenyl, alkynyl, cycloalkyl, and heterocycloalkyl are substituted with m R c; Y is selected from O, S, -NR a, and -C(R a R b)-; L is selected from C 1-10 alkylene, C 2-10 alkenylene, and C 2-10 alkynylene; wherein the alkylene, alkenylene, and alkynylene are substituted with m R c; m is independently 0, 1, 2, 3, or 4; R a and R b are independently selected from hydrogen, C 1-10 alkyl, C 2-10 alkenyl, C 2-10 alkynyl, 3-10 membered cycloalkyl, and 3-10 membered heterocycloalkyl; and R c is independently selected from C 1-10 alkyl, halogen, -CN, -NO 2, -OR a, -OC R a, - OS 2 R a, -SR a, -S 2 R a, -S 2 NR a R b, -C R a, -C OR a, -C NR a R b, -NR a R b, -NR a C R b, and -NR a S 2 R b, or a stereoisomer thereof, or a pharmaceutically acceptable salt thereof.