Maven compile gives: Cannot find symbol - For a class sitting in the same app

后端 未结 3 1394
耶瑟儿~
耶瑟儿~ 2021-02-20 14:13

It\'s a while since I met such puzzling issue. I\'m having a class that references another one sitting in another package in the same application, that is, NOT in another jar ar

3条回答
  •  轮回少年
    2021-02-20 14:43

    With maven your tests can access to all the source code of your project (src/main/java) and all the test source code (default is src/test/java).

    Here, your profile rest defines the test source directory as src/test/java/com/thalasoft/learnintouch/rest So, your test code can access everything in src/main/java and everything in src/test/java/com/thalasoft/learnintouch/rest

    Your profile acceptance defines the test source directory as src/test/java/com/thalasoft/learnintouch/rest/acceptance So, your test code can access everything in src/main/java and everything in src/test/java/com/thalasoft/learnintouch/rest/acceptance. WebTestConfiguration is not accessible since it's in a package above.

    To run specific tests with different profiles, I recommend to configure the surefire plugin in charge of running tests. A good example is available here : https://weblogs.java.net/blog/carcassi/archive/2011/04/21/running-integration-tests-and-unit-tests-separately-maven

提交回复
热议问题