SHANGHAI — He Junwei traveled about 100 miles on a high-speed train to wait an hour for a cup of coffee.

Mr. He was one of hundreds of Chinese caffeine fiends gathered to visit what essentially serves as a tribute built by Starbucks in their honor. The American company on Wednesday opened its largest store in the world in Shanghai, a 29,000-square-foot sanctuary staffed by 400 employees.

The giant cafe represents the big bet it has placed on a country that until only recently much preferred tea. Starbucks has opened more than 3,000 stores in the country and plans to have 5,000 in four years.