Target detection is a hot spot in hyperspectral imagery (HSI) processing. The detection accuracy of target detection algorithms based on sparse representation (SR) models usually suffers from the high reconstruction residuals caused by inaccurate background estimations and insufficient target samples. Besides, with the development of hyperspectral imaging technology, the spatial resolution of HSI has been continuously enhanced, which can provide more spatial information for target detection. However, spatial information is often overlooked, leading to the underutilization of the pluralistic features of HSI. Target detection using only spectral information is susceptible to spectral variation, resulting in a high false alarm rate. To alleviate these problems, this paper proposes a joint spatial-spectral algorithm. In terms of spectra, a dictionary construction strategy (DCS) is designed for the sparse representation-based binary hypothesis (SRBBH) detector to reduce reconstruction residuals of target and background samples. In terms of space, k-means 2D adaptive singular spectrum analysis (KSSA) is used to extract spatial features in cluster units. Using spatial features can enhance the robustness of the algorithm to spectral variation, thereby reducing false alarms. The target detection results are obtained by applying DCS-SRBBH to the KSSA feature image. We evaluate the proposed algorithm on three datasets: two public and one of our own. Comprehensive experimental results indicate that the proposed algorithm outperforms other target detection algorithms in terms of accuracy.